edu.emory.mathcs.util.collections.longs
Class LongArrayList

java.lang.Object
  extended byedu.emory.mathcs.util.collections.longs.AbstractLongCollection
      extended byedu.emory.mathcs.util.collections.longs.LongArrayList
All Implemented Interfaces:
LongCollection, LongList

public class LongArrayList
extends AbstractLongCollection
implements LongList

Array-based list of long numbers.

Version:
1.0
Author:
Dawid Kurzyniec

Constructor Summary
LongArrayList()
          Creates a LongArrayList with initial capacity of 10.
LongArrayList(int initialCapacity)
          Creates a LongArrayList with the specified initial capacity.
LongArrayList(LongCollection c)
          Creates a LongArrayList, copying to it all elements from the specified long collection, in the order as returned by that collection's iterator.
 
Method Summary
 boolean add(long e)
          Attempts to add the specified number to this collection.
 boolean addAll(int index, LongCollection c)
           
 boolean addAll(LongCollection c)
          Attempts to add to this collection all the numbers contained in the specified collection.
 void addAt(int index, long e)
          Adds the value at the specified index, and moves elements starting at index to the right.
 void clear()
          Removes all the numbers from this collection.
 boolean contains(long e)
          Returns true if this collection contains specified number; false otherwise.
 boolean equals(java.lang.Object o)
           
 long getAt(int index)
          Returns the value at the specified index.
 int hashCode()
           
 int indexOf(long e)
          Returns the smallest index at which the list contains the specified number.
 boolean isEmpty()
          Returns true if this collection is empty; false otherwise.
 LongIterator iterator()
          Returns the iterator over numbers contained in this collection.
 int lastIndexOf(long e)
          Returns the largest index at which the list contains the specified number.
 LongListIterator listIterator()
           
 LongListIterator listIterator(int index)
           
 boolean remove(long e)
          Attempts to remove the specified number from this collection.
 long removeAt(int index)
          Removes the value at the specified index, and shifts elements starting at index+1 to the left.
 long setAt(int index, long e)
          Sets the value at the specified index.
 int size()
          Returns the number of elements in this collection.
 long size64()
          // PREPROC: Long,Int only Returns the number of elements in this collection.
 LongList subList(int fromIndex, int toIndex)
           
 long[] toArray()
          Returns the newly allocated array containing all numbers from this collection, in the order returned by its iterator.
 long[] toArray(long[] a)
          Returns an array containing all of the numbers in this collection.
 
Methods inherited from class edu.emory.mathcs.util.collections.longs.AbstractLongCollection
containsAll, removeAll, retainAll, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface edu.emory.mathcs.util.collections.longs.LongList
containsAll, removeAll, retainAll
 

Constructor Detail

LongArrayList

public LongArrayList()
Creates a LongArrayList with initial capacity of 10.


LongArrayList

public LongArrayList(int initialCapacity)
Creates a LongArrayList with the specified initial capacity.


LongArrayList

public LongArrayList(LongCollection c)
Creates a LongArrayList, copying to it all elements from the specified long collection, in the order as returned by that collection's iterator.

Method Detail

size

public int size()
Description copied from interface: LongCollection
Returns the number of elements in this collection. If exceeds Integer.MAX_VALUE, then Integer.MAX_VALUE is returned. // PREPROC: Long,Int only

Specified by:
size in interface LongList
Overrides:
size in class AbstractLongCollection

isEmpty

public boolean isEmpty()
Description copied from interface: LongCollection
Returns true if this collection is empty; false otherwise.

Specified by:
isEmpty in interface LongList
Overrides:
isEmpty in class AbstractLongCollection

contains

public boolean contains(long e)
Description copied from interface: LongCollection
Returns true if this collection contains specified number; false otherwise.

Specified by:
contains in interface LongList
Overrides:
contains in class AbstractLongCollection

iterator

public LongIterator iterator()
Description copied from interface: LongCollection
Returns the iterator over numbers contained in this collection.

Specified by:
iterator in interface LongList
Specified by:
iterator in class AbstractLongCollection

toArray

public long[] toArray()
Description copied from interface: LongCollection
Returns the newly allocated array containing all numbers from this collection, in the order returned by its iterator.

Specified by:
toArray in interface LongList
Overrides:
toArray in class AbstractLongCollection

toArray

public long[] toArray(long[] a)
Description copied from interface: LongCollection
Returns an array containing all of the numbers in this collection. If the collection fits in the specified array, it is returned therein. Otherwise, a new array is allocated.

If this collection makes any guarantees as to what order its elements are returned by its iterator, this method must return the elements in the same order.

Like the LongCollection.toArray() method, this method acts as bridge between array-based and collection-based APIs. Further, this method may, under certain circumstances, be used to save allocation costs.

Specified by:
toArray in interface LongList
Overrides:
toArray in class AbstractLongCollection

add

public boolean add(long e)
Description copied from interface: LongCollection
Attempts to add the specified number to this collection. Returns true if the collection was modified as a result of this call; false otherwise.

Specified by:
add in interface LongList
Overrides:
add in class AbstractLongCollection

remove

public boolean remove(long e)
Description copied from interface: LongCollection
Attempts to remove the specified number from this collection. Returns true if the collection was modified as a result of this call; false otherwise.

Specified by:
remove in interface LongList
Overrides:
remove in class AbstractLongCollection

addAll

public boolean addAll(LongCollection c)
Description copied from interface: LongCollection
Attempts to add to this collection all the numbers contained in the specified collection. Returns true if the collection was modified as a result of this call; false otherwise.

Specified by:
addAll in interface LongList
Overrides:
addAll in class AbstractLongCollection

addAll

public boolean addAll(int index,
                      LongCollection c)
Specified by:
addAll in interface LongList

clear

public void clear()
Description copied from interface: LongCollection
Removes all the numbers from this collection.

Specified by:
clear in interface LongList
Overrides:
clear in class AbstractLongCollection

equals

public boolean equals(java.lang.Object o)
Specified by:
equals in interface LongList

hashCode

public int hashCode()
Specified by:
hashCode in interface LongList

getAt

public long getAt(int index)
Description copied from interface: LongList
Returns the value at the specified index.

Specified by:
getAt in interface LongList
Parameters:
index - the index to retrieve the value from.
Returns:
the value at the specified index.

setAt

public long setAt(int index,
                  long e)
Description copied from interface: LongList
Sets the value at the specified index.

Specified by:
setAt in interface LongList
Parameters:
index - the index to set the value at.
e - the new value.
Returns:
the value previously present the specified index.

addAt

public void addAt(int index,
                  long e)
Description copied from interface: LongList
Adds the value at the specified index, and moves elements starting at index to the right.

Specified by:
addAt in interface LongList
Parameters:
index - the index to add the value at.
e - the new value.

removeAt

public long removeAt(int index)
Description copied from interface: LongList
Removes the value at the specified index, and shifts elements starting at index+1 to the left.

Specified by:
removeAt in interface LongList
Parameters:
index - the index to remove the value from.
Returns:
the value previously present at the specified index.

indexOf

public int indexOf(long e)
Description copied from interface: LongList
Returns the smallest index at which the list contains the specified number.

Specified by:
indexOf in interface LongList
Parameters:
e - the number to look for
Returns:
the smallest index of e

lastIndexOf

public int lastIndexOf(long e)
Description copied from interface: LongList
Returns the largest index at which the list contains the specified number.

Specified by:
lastIndexOf in interface LongList
Parameters:
e - the number to look for
Returns:
the largest index of e

listIterator

public LongListIterator listIterator()
Specified by:
listIterator in interface LongList

listIterator

public LongListIterator listIterator(int index)
Specified by:
listIterator in interface LongList

subList

public LongList subList(int fromIndex,
                        int toIndex)
Specified by:
subList in interface LongList

size64

public long size64()
Description copied from interface: LongCollection
// PREPROC: Long,Int only Returns the number of elements in this collection. // PREPROC: Long,Int only

Specified by:
size64 in interface LongCollection
Overrides:
size64 in class AbstractLongCollection