org.rutil.collection
Class FileBackedArrayList<T extends java.io.Serializable>

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by java.util.AbstractList<E>
          extended by java.util.AbstractSequentialList<T>
              extended by org.rutil.collection.FileBackedArrayList<T>
All Implemented Interfaces:
java.io.Serializable, java.lang.Iterable<T>, java.util.Collection<T>, java.util.List<T>

public class FileBackedArrayList<T extends java.io.Serializable>
extends java.util.AbstractSequentialList<T>
implements java.util.List<T>, java.io.Serializable

An array list backed by a file store where the indexes are stored in memory and the actual values are stored in a file. Useful to store large values that are accessed by their index and/or accessed sequentially.

Author:
mohan
See Also:
Serialized Form

Field Summary
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
FileBackedArrayList(SerializableObjectsFile<T> file)
           
 
Method Summary
 boolean add(T e)
           
 long addAndGetPosition(T e)
           
 void clear()
           
 T get(int index)
           
 java.util.ListIterator<T> listIterator(int index)
           
 T removeAt(int index)
           
 T set(int index, T value)
           
 int size()
           
 void trim()
           
 
Methods inherited from class java.util.AbstractSequentialList
add, addAll, iterator, remove
 
Methods inherited from class java.util.AbstractList
equals, hashCode, indexOf, lastIndexOf, listIterator, 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
add, addAll, addAll, contains, containsAll, equals, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, remove, remove, removeAll, retainAll, subList, toArray, toArray
 

Constructor Detail

FileBackedArrayList

public FileBackedArrayList(SerializableObjectsFile<T> file)
Method Detail

size

public int size()
Specified by:
size in interface java.util.Collection<T extends java.io.Serializable>
Specified by:
size in interface java.util.List<T extends java.io.Serializable>
Specified by:
size in class java.util.AbstractCollection<T extends java.io.Serializable>

add

public boolean add(T e)
Specified by:
add in interface java.util.Collection<T extends java.io.Serializable>
Specified by:
add in interface java.util.List<T extends java.io.Serializable>
Overrides:
add in class java.util.AbstractList<T extends java.io.Serializable>

addAndGetPosition

public long addAndGetPosition(T e)

set

public T set(int index,
             T value)
                                   throws java.lang.UnsupportedOperationException
Specified by:
set in interface java.util.List<T extends java.io.Serializable>
Overrides:
set in class java.util.AbstractSequentialList<T extends java.io.Serializable>
Throws:
java.lang.UnsupportedOperationException

get

public T get(int index)
Specified by:
get in interface java.util.List<T extends java.io.Serializable>
Overrides:
get in class java.util.AbstractSequentialList<T extends java.io.Serializable>

removeAt

public T removeAt(int index)

clear

public void clear()
Specified by:
clear in interface java.util.Collection<T extends java.io.Serializable>
Specified by:
clear in interface java.util.List<T extends java.io.Serializable>
Overrides:
clear in class java.util.AbstractList<T extends java.io.Serializable>

trim

public void trim()

listIterator

public java.util.ListIterator<T> listIterator(int index)
Specified by:
listIterator in interface java.util.List<T extends java.io.Serializable>
Specified by:
listIterator in class java.util.AbstractSequentialList<T extends java.io.Serializable>