fiftyone.mobile.detection.entities.memory
Class BaseList<T extends BaseEntity>

java.lang.Object
  extended by fiftyone.mobile.detection.entities.memory.BaseList<T>
Type Parameters:
T - The type the list will contain.
All Implemented Interfaces:
Disposable, ReadonlyList<T>, Iterable<T>
Direct Known Subclasses:
MemoryFixedList, MemoryVariableList

public abstract class BaseList<T extends BaseEntity>
extends Object
implements ReadonlyList<T>, Disposable

Lists can be stored as a set of related objects entirely within memory, or the relevant objects loaded as required from a file or other permanent store as required.

This class provides base functions for lists implemented in memory using arrays of type T.

Interfaces are used to create new instances of items to add to the list in order to avoid creating many inherited list classes for each type.

The data is held in the private variable array.

Should not be referenced directly.


Field Summary
protected  List<T> array
          Array of items contained in the list.
protected  Dataset dataSet
          The dataset which contains the list.
protected  BaseEntityFactory<T> entityFactory
          Interface used to create a new instance of an item in the list.
 Header header
          Information about the data structure the list is associated with.
 
Constructor Summary
BaseList(Dataset dataSet, BinaryReader reader, BaseEntityFactory<T> entityFactory)
          Constructs a new instance of .
 
Method Summary
 void dispose()
          Dispose of any items the list holds open.
 Iterator<T> iterator()
           
 int size()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface fiftyone.mobile.detection.ReadonlyList
get
 

Field Detail

header

public final Header header
Information about the data structure the list is associated with.


dataSet

protected final Dataset dataSet
The dataset which contains the list.


entityFactory

protected final BaseEntityFactory<T extends BaseEntity> entityFactory
Interface used to create a new instance of an item in the list.


array

protected final List<T extends BaseEntity> array
Array of items contained in the list.

Constructor Detail

BaseList

BaseList(Dataset dataSet,
         BinaryReader reader,
         BaseEntityFactory<T> entityFactory)
Constructs a new instance of . The read method needs to be called following construction to read all the entities which form the list before the list can be used.

Parameters:
dataSet - Dataset being created
reader - Reader used to initialise the header
entityFactory - Interface used to create new entities of type T from the read method
Method Detail

dispose

public void dispose()
Dispose of any items the list holds open. Currently unimplemented.

Specified by:
dispose in interface Disposable

iterator

public Iterator<T> iterator()
Specified by:
iterator in interface Iterable<T extends BaseEntity>
Returns:
An iterator to the array of items.

size

public int size()
Specified by:
size in interface ReadonlyList<T extends BaseEntity>
Returns:
The number of entities the list contains.