INSTANCE
- the type of instances in the datasetSOURCE
- the type of object that provides the data to create the instancepublic abstract class ReadableListDataset<INSTANCE,SOURCE> extends AbstractList<INSTANCE> implements ListDataset<INSTANCE>
ListDataset
s in which each instance is read with an
InputStreamObjectReader
.Modifier and Type | Field and Description |
---|---|
protected ObjectReader<INSTANCE,SOURCE> |
reader |
modCount
Constructor and Description |
---|
ReadableListDataset(ObjectReader<INSTANCE,SOURCE> reader)
Construct with the given
ObjectReader . |
Modifier and Type | Method and Description |
---|---|
INSTANCE |
get(int index) |
String |
getID(int index)
Get an identifier for the instance at the given index.
|
INSTANCE |
getRandomInstance() |
int |
indexOfID(String id)
Get the index of the instance with the given ID, or -1 if it can't be
found.
|
int |
size() |
ListDataset<IdentifiableObject<INSTANCE>> |
toIdentifiable()
Create a view of this dataset in which the instances are wrapped up in
IdentifiableObject s. |
add, add, addAll, clear, equals, hashCode, indexOf, iterator, lastIndexOf, listIterator, listIterator, remove, removeRange, set, subList
addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toString
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
getInstance
numInstances
add, add, addAll, addAll, clear, contains, containsAll, equals, hashCode, indexOf, isEmpty, iterator, lastIndexOf, listIterator, listIterator, remove, remove, removeAll, replaceAll, retainAll, set, sort, spliterator, subList, toArray, toArray
parallelStream, removeIf, stream
protected ObjectReader<INSTANCE,SOURCE> reader
public ReadableListDataset(ObjectReader<INSTANCE,SOURCE> reader)
ObjectReader
.reader
- the InputStreamObjectReader
.public INSTANCE getRandomInstance()
getRandomInstance
in interface Dataset<INSTANCE>
public String getID(int index)
String
, but sub-classes
should override to to something more sensible if possible.index
- the indexpublic int indexOfID(String id)
id
- the ID stringpublic final int size()
size
in interface Collection<INSTANCE>
size
in interface List<INSTANCE>
size
in class AbstractCollection<INSTANCE>
public ListDataset<IdentifiableObject<INSTANCE>> toIdentifiable()
IdentifiableObject
s. The getID(int)
method is used to
determine the identifier.Identifiable
-wrapped
instances