jodd.util.collection
Class LongArrayList

java.lang.Object
  extended by jodd.util.collection.LongArrayList
All Implemented Interfaces:
java.io.Serializable

public class LongArrayList
extends java.lang.Object
implements java.io.Serializable

ArrayList of long primitives.

See Also:
Serialized Form

Field Summary
static int INITIAL_CAPACITY
           
 
Constructor Summary
LongArrayList()
          Constructs an empty list with an initial capacity.
LongArrayList(int initialCapacity)
          Constructs an empty list with the specified initial capacity.
LongArrayList(long[] data)
          Constructs a list containing the elements of the specified array.
 
Method Summary
 void add(int index, long element)
          Inserts the specified element at the specified position in this list.
 void add(long element)
          Appends the specified element to the end of this list.
 void addAll(int index, long[] data)
          Appends all of the elements in the specified array at the specified position in this list.
 void addAll(long[] data)
          Appends all of the elements in the specified array to the end of this list.
 void clear()
          Removes all of the elements from this list.
 boolean contains(long data)
          Returns true if this list contains the specified element.
 void ensureCapacity(int mincap)
          Increases the capacity of this ArrayList instance, if necessary, to ensure that it can hold at least the number of elements specified by the minimum capacity argument.
 long get(int index)
          Returns the element at the specified position in this list.
 int indexOf(long data)
          Searches for the first occurrence of the given argument.
 boolean isEmpty()
          Tests if this list has no elements.
 int lastIndexOf(long data)
          Returns the index of the last occurrence of the specified object in this list.
 long remove(int index)
          Removes the element at the specified position in this list.
 void removeRange(int fromIndex, int toIndex)
          Removes from this list all of the elements whose index is between fromIndex, inclusive and toIndex, exclusive.
 long set(int index, long element)
          Replaces the element at the specified position in this list with the specified element.
 int size()
          Returns the number of elements in this list.
 long[] toArray()
          Returns an array containing all of the elements in this list in the correct order.
 void trimToSize()
          Trims the capacity of this instance to be the list's current size.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INITIAL_CAPACITY

public static int INITIAL_CAPACITY
Constructor Detail

LongArrayList

public LongArrayList()
Constructs an empty list with an initial capacity.


LongArrayList

public LongArrayList(int initialCapacity)
Constructs an empty list with the specified initial capacity.


LongArrayList

public LongArrayList(long[] data)
Constructs a list containing the elements of the specified array. The list instance has an initial capacity of 110% the size of the specified array.

Method Detail

toArray

public long[] toArray()
Returns an array containing all of the elements in this list in the correct order.


get

public long get(int index)
Returns the element at the specified position in this list.


size

public int size()
Returns the number of elements in this list.


remove

public long remove(int index)
Removes the element at the specified position in this list. Shifts any subsequent elements to the left (subtracts one from their indices).

Parameters:
index - the index of the element to remove
Returns:
the value of the element that was removed
Throws:
java.lang.UnsupportedOperationException - when this operation is not supported
java.lang.IndexOutOfBoundsException - if the specified index is out of range

removeRange

public void removeRange(int fromIndex,
                        int toIndex)
Removes from this list all of the elements whose index is between fromIndex, inclusive and toIndex, exclusive. Shifts any succeeding elements to the left (reduces their index).


set

public long set(int index,
                long element)
Replaces the element at the specified position in this list with the specified element.

Parameters:
index - the index of the element to change
element - the value to be stored at the specified position
Returns:
the value previously stored at the specified position

add

public void add(long element)
Appends the specified element to the end of this list.


add

public void add(int index,
                long element)
Inserts the specified element at the specified position in this list. Shifts the element currently at that position (if any) and any subsequent elements to the right (adds one to their indices).

Parameters:
index - the index at which to insert the element
element - the value to insert

addAll

public void addAll(long[] data)
Appends all of the elements in the specified array to the end of this list.


addAll

public void addAll(int index,
                   long[] data)
Appends all of the elements in the specified array at the specified position in this list.


clear

public void clear()
Removes all of the elements from this list. The list will be empty after this call returns.


contains

public boolean contains(long data)
Returns true if this list contains the specified element.


indexOf

public int indexOf(long data)
Searches for the first occurrence of the given argument.


lastIndexOf

public int lastIndexOf(long data)
Returns the index of the last occurrence of the specified object in this list.


isEmpty

public boolean isEmpty()
Tests if this list has no elements.


ensureCapacity

public void ensureCapacity(int mincap)
Increases the capacity of this ArrayList instance, if necessary, to ensure that it can hold at least the number of elements specified by the minimum capacity argument.


trimToSize

public void trimToSize()
Trims the capacity of this instance to be the list's current size. An application can use this operation to minimize the storage of some instance.



Copyright ©2008 Jodd Team