edu.emory.mathcs.util.collections.ints
Class IntArrayList

java.lang.Object
  extended byedu.emory.mathcs.util.collections.ints.AbstractIntCollection
      extended byedu.emory.mathcs.util.collections.ints.IntArrayList
All Implemented Interfaces:
IntCollection, IntList

public class IntArrayList
extends AbstractIntCollection
implements IntList

Array-based list of int numbers.

Version:
1.0
Author:
Dawid Kurzyniec

Constructor Summary
IntArrayList()
          Creates a IntArrayList with initial capacity of 10.
IntArrayList(int initialCapacity)
          Creates a IntArrayList with the specified initial capacity.
IntArrayList(IntCollection c)
          Creates a IntArrayList, copying to it all elements from the specified int collection, in the order as returned by that collection's iterator.
 
Method Summary
 boolean add(int e)
          Attempts to add the specified number to this collection.
 boolean addAll(IntCollection c)
          Attempts to add to this collection all the numbers contained in the specified collection.
 boolean addAll(int index, IntCollection c)
           
 void addAt(int index, int 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(int e)
          Returns true if this collection contains specified number; false otherwise.
 boolean equals(java.lang.Object o)
           
 int getAt(int index)
          Returns the value at the specified index.
 int hashCode()
           
 int indexOf(int e)
          Returns the smallest index at which the list contains the specified number.
 boolean isEmpty()
          Returns true if this collection is empty; false otherwise.
 IntIterator iterator()
          Returns the iterator over numbers contained in this collection.
 int lastIndexOf(int e)
          Returns the largest index at which the list contains the specified number.
 IntListIterator listIterator()
           
 IntListIterator listIterator(int index)
           
 boolean remove(int e)
          Attempts to remove the specified number from this collection.
 int removeAt(int index)
          Removes the value at the specified index, and shifts elements starting at index+1 to the left.
 int setAt(int index, int e)
          Sets the value at the specified index.
 int size()
          Returns the number of elements in this collection.
 int size64()
          Returns the number of elements in this collection.
 IntList subList(int fromIndex, int toIndex)
           
 int[] toArray()
          Returns the newly allocated array containing all numbers from this collection, in the order returned by its iterator.
 int[] toArray(int[] a)
          Returns an array containing all of the numbers in this collection.
 
Methods inherited from class edu.emory.mathcs.util.collections.ints.AbstractIntCollection
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.ints.IntList
containsAll, removeAll, retainAll
 

Constructor Detail

IntArrayList

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


IntArrayList

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


IntArrayList

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

Method Detail

size

public int size()
Description copied from interface: IntCollection
Returns the number of elements in this collection. If exceeds Integer.MAX_VALUE, then Integer.MAX_VALUE is returned.

Specified by:
size in interface IntList
Overrides:
size in class AbstractIntCollection

isEmpty

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

Specified by:
isEmpty in interface IntList
Overrides:
isEmpty in class AbstractIntCollection

contains

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

Specified by:
contains in interface IntList
Overrides:
contains in class AbstractIntCollection

iterator

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

Specified by:
iterator in interface IntList
Specified by:
iterator in class AbstractIntCollection

toArray

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

Specified by:
toArray in interface IntList
Overrides:
toArray in class AbstractIntCollection

toArray

public int[] toArray(int[] a)
Description copied from interface: IntCollection
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 IntCollection.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 IntList
Overrides:
toArray in class AbstractIntCollection

add

public boolean add(int e)
Description copied from interface: IntCollection
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 IntList
Overrides:
add in class AbstractIntCollection

remove

public boolean remove(int e)
Description copied from interface: IntCollection
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 IntList
Overrides:
remove in class AbstractIntCollection

addAll

public boolean addAll(IntCollection c)
Description copied from interface: IntCollection
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 IntList
Overrides:
addAll in class AbstractIntCollection

addAll

public boolean addAll(int index,
                      IntCollection c)
Specified by:
addAll in interface IntList

clear

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

Specified by:
clear in interface IntList
Overrides:
clear in class AbstractIntCollection

equals

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

hashCode

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

getAt

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

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

setAt

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

Specified by:
setAt in interface IntList
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,
                  int e)
Description copied from interface: IntList
Adds the value at the specified index, and moves elements starting at index to the right.

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

removeAt

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

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

indexOf

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

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

lastIndexOf

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

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

listIterator

public IntListIterator listIterator()
Specified by:
listIterator in interface IntList

listIterator

public IntListIterator listIterator(int index)
Specified by:
listIterator in interface IntList

subList

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

size64

public int size64()
Description copied from interface: IntCollection
Returns the number of elements in this collection.

Specified by:
size64 in interface IntCollection
Overrides:
size64 in class AbstractIntCollection