org.shiftone.exq.impl.util
Class FastList

java.lang.Object
  extended byjava.util.AbstractCollection
      extended byjava.util.AbstractList
          extended byorg.shiftone.exq.impl.util.FastList
All Implemented Interfaces:
java.util.Collection, java.util.List

public class FastList
extends java.util.AbstractList

implementation of the list interface. This trades off features (remove, resize) in favor of better performance. Sun's implementation of ArrayList resizes itself when it's capacity is reached, which is done with array copying. This list keeps an array of arrays. When the capacity is reached, a new sub array is added to a master array. Was this really necessary?


Nested Class Summary
 
Nested classes inherited from class java.util.AbstractList
 
Field Summary
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
FastList()
          equivelant to FastList(8) - creates list with 65,536 element capacity
FastList(int bits)
          Creates a list with a max capacity of (2^bits)^2 elelments.
 
Method Summary
 boolean add(java.lang.Object element)
          Method add
 int capacity()
          Method capacity
 void clear()
          Method clear
 java.lang.Object get(int i)
          Method get
 java.lang.Object set(int i, java.lang.Object element)
          Method set
 int size()
          Method size
 
Methods inherited from class java.util.AbstractList
add, addAll, equals, hashCode, indexOf, iterator, lastIndexOf, listIterator, listIterator, remove, removeRange, subList
 
Methods inherited from class java.util.AbstractCollection
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.List
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray
 

Constructor Detail

FastList

public FastList(int bits)
Creates a list with a max capacity of (2^bits)^2 elelments.
 bits          capacity
 5        32      1,024
 6        64      4,096
 7        128     16,384
 8        256     65,536
 9        512     262,144
 10       1,024   1,048,576
 11       2,048   4,194,304
 12       4,096   16,777,216
 13       8,192   67,108,864
 14       16,384  268,435,456
 15       32,768  1,073,741,824
 16       65,536  4,294,967,296
     

Parameters:
bits -

FastList

public FastList()
equivelant to FastList(8) - creates list with 65,536 element capacity

Method Detail

set

public java.lang.Object set(int i,
                            java.lang.Object element)
Method set

Parameters:
i -
element -

add

public boolean add(java.lang.Object element)
Method add

Parameters:
element -

get

public java.lang.Object get(int i)
Method get

Parameters:
i -

clear

public void clear()
Method clear


capacity

public final int capacity()
Method capacity


size

public final int size()
Method size