uk.ac.man.bioinf.util
Class IntArrayList

java.lang.Object
  |
  +--uk.ac.man.bioinf.util.IntArrayList

public class IntArrayList
extends Object

IntArrayList.java This class provides something akin to the ArrayList class but with all the methods typed as ints, which avoids the additional bloat of having to create an object for every containined integer. Created: Fri Mar 3 23:28:54 2000

Version:
$Id: IntArrayList.java,v 1.6 2001/04/11 17:04:43 lord Exp $
Author:
Phillip Lord

Constructor Summary
IntArrayList()
           
IntArrayList(int initialCapacity)
           
 
Method Summary
 void add(int value)
           
 void add(int index, int value)
           
 int binarySearch(int key)
          This method performs a binary search on the list.
 void clear()
           
 boolean contains(int elem)
           
 void ensureCapacity(int minCapacity)
           
 boolean equals(IntArrayList list)
           
 int get(int index)
           
 IntArrayList getSubList(int position, int length)
           
 int indexOf(int elem)
           
 boolean isEmpty()
           
 int lastIndexOf(int elem)
           
 int linearSearch(int key)
          Provides a linear search.
 void print()
           
 int remove(int index)
           
 int[] remove(int index, int length)
           
 int set(int index, int value)
           
 int size()
           
 void sort()
          Sort the contents of this list.
 int[] toArray()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IntArrayList

public IntArrayList()

IntArrayList

public IntArrayList(int initialCapacity)
Method Detail

ensureCapacity

public void ensureCapacity(int minCapacity)

size

public int size()

isEmpty

public boolean isEmpty()

contains

public boolean contains(int elem)

indexOf

public int indexOf(int elem)

lastIndexOf

public int lastIndexOf(int elem)

get

public int get(int index)

set

public int set(int index,
               int value)

add

public void add(int value)

add

public void add(int index,
                int value)

remove

public int remove(int index)

remove

public int[] remove(int index,
                    int length)

clear

public void clear()

getSubList

public IntArrayList getSubList(int position,
                               int length)

toArray

public int[] toArray()

sort

public void sort()
Sort the contents of this list. Does it via a modified quicksort. Which I didnt write.


binarySearch

public int binarySearch(int key)
This method performs a binary search on the list. If you choose to use this method on a list which is not guarenteed to be sorted for instance by the sort method then dealing with the results is distinctly your problem.

Parameters:
key - the key to search for
Returns:
the position the key is at or its insertion point.
See Also:
Arrays.binarySearch(int[],int)

linearSearch

public int linearSearch(int key)
Provides a linear search. This works even if the list is not sorted, but operates in, well linear, time.

Parameters:
key - the key to search for
Returns:
the index or -1 if not found

equals

public boolean equals(IntArrayList list)

print

public void print()