fiftyone.mobile.detection.entities.stream
Class BaseList<T extends BaseEntity>
java.lang.Object
fiftyone.mobile.detection.entities.stream.BaseList<T>
- All Implemented Interfaces:
- Disposable, ICacheList, ReadonlyList<T>, Iterable<T>
- Direct Known Subclasses:
- StreamFixedList, StreamVariableList
public abstract class BaseList<T extends BaseEntity>
- extends Object
- implements ReadonlyList<T>, ICacheList, 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 core functions needed for lists which
load objects as required. It implements the Cache to store frequently
requested objects and improve memory usage and performance. Interface
implementations are used to create new instances of items to add to the list
in order to avoid creating many inherited list classes for each BaseEntity
type.
Should not be referenced directly.
|
Field Summary |
Cache<T> |
cache
Used to store previously accessed items to improve performance and reduce
memory consumption associated with creating new instances of entities
already in use. |
protected Dataset |
dataSet
The dataset which contains the list. |
(package private) BaseEntityFactory<T> |
entityFactory
|
(package private) Header |
header
Information about the data structure the list is associated with. |
(package private) Pool |
pool
Pools of binary readers connected to the data source. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
cache
public final Cache<T extends BaseEntity> cache
- Used to store previously accessed items to improve performance and reduce
memory consumption associated with creating new instances of entities
already in use.
pool
final Pool pool
- Pools of binary readers connected to the data source.
dataSet
protected final Dataset dataSet
- The dataset which contains the list.
header
final Header header
- Information about the data structure the list is associated with.
entityFactory
final BaseEntityFactory<T extends BaseEntity> entityFactory
BaseList
public BaseList(Dataset dataSet,
BinaryReader reader,
Source source,
BaseEntityFactory<T> entityFactory)
- Constructs a new instance of BaseList ready to read entities from the
source.
- Parameters:
dataSet - Dataset being createdreader - Reader used to initialise the header onlysource - Source data file containing the entire data structure
createEntity
protected abstract T createEntity(int offset,
BinaryReader reader)
throws IOException
- Throws:
IOException
getPercentageMisses
public double getPercentageMisses()
- Specified by:
getPercentageMisses in interface ICacheList
getCount
public int getCount()
get
public T get(int offsetOrIndex)
throws IOException
- Retrieves the record at the offset or index requested
- Specified by:
get in interface ReadonlyList<T extends BaseEntity>
- Parameters:
offsetOrIndex - Index or offset of the record required
- Returns:
- A new instance of the item at the offset or index
- Throws:
IOException
dispose
public void dispose()
- Disposes of the pool of readers.
- Specified by:
dispose in interface Disposable
size
public int size()
- Specified by:
size in interface ReadonlyList<T extends BaseEntity>