fiftyone.mobile.detection.entities.stream
Class StreamVariableList<T extends BaseEntity>

java.lang.Object
  extended by fiftyone.mobile.detection.entities.stream.BaseList<T>
      extended by fiftyone.mobile.detection.entities.stream.StreamVariableList<T>
All Implemented Interfaces:
Disposable, ICacheList, ReadonlyList<T>, Iterable<T>

public class StreamVariableList<T extends BaseEntity>
extends BaseList<T>

A readonly list of variable length entity types held on persistent storage rather than in memory.

Entities in the underlying data structure are either fixed length where the data that represents them always contains the same number of bytes, or variable length where the number of bytes to represent the entity varies.

This class uses the offset of the first byte of the entities data in the underlying data structure in the accessor. As such the list isn't being used as a traditional list because items are not retrieved by their index in the list, but by there offset in the underlying data structure.

The constructor will read the header information about the underlying data structure. The data for each entity is only loaded when requested via the accessor. A cache is used to avoid creating duplicate objects when requested multiple times.

Data sources which don't support seeking can not be used. Specifically compressed data structures can not be used with these lists.

Should not be referenced directly.


Field Summary
 
Fields inherited from class fiftyone.mobile.detection.entities.stream.BaseList
cache, dataSet, entityFactory, header, pool
 
Constructor Summary
StreamVariableList(Dataset dataSet, BinaryReader reader, Source source, BaseEntityFactory<T> entityFactory)
          Constructs a new instance of VariableList
 
Method Summary
protected  T createEntity(int offset, BinaryReader reader)
          Creates a new entity of type T.
 Iterator<T> iterator()
           
 
Methods inherited from class fiftyone.mobile.detection.entities.stream.BaseList
dispose, get, getCount, getPercentageMisses, size
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StreamVariableList

public StreamVariableList(Dataset dataSet,
                          BinaryReader reader,
                          Source source,
                          BaseEntityFactory<T> entityFactory)
Constructs a new instance of VariableList

Parameters:
dataSet - The DetectorDataSet being created
reader - Reader connected to the source data structure and positioned to start reading
entityFactory - Factory to build entities of type T
source - Reference to the underlying data structure
Method Detail

createEntity

protected T createEntity(int offset,
                         BinaryReader reader)
                                     throws IOException
Creates a new entity of type T.

Specified by:
createEntity in class BaseList<T extends BaseEntity>
Parameters:
offset - The offset of the entity being created
reader - Reader connected to the source data structure and positioned to start reading
Returns:
A new entity of type T at the offset provided
Throws:
IOException

iterator

public Iterator<T> iterator()