KEY - Type of dataset class keyDATASET - Type of sub-datasets.INSTANCE - Type of objects in the datasetpublic class MapBackedDataset<KEY,DATASET extends Dataset<INSTANCE>,INSTANCE> extends AbstractMap<KEY,DATASET> implements GroupedDataset<KEY,DATASET,INSTANCE>
| Modifier and Type | Class and Description |
|---|---|
static class |
MapBackedDataset.IdentifiableBuilder<DATASET extends Dataset<INSTANCE> & Identifiable,INSTANCE>
A builder for creating
MapBackedDataset instances from
Identifiable sub-datasets. |
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>| Constructor and Description |
|---|
MapBackedDataset()
Construct an empty
MapBackedDataset backed by a HashMap. |
MapBackedDataset(Map<KEY,DATASET> map)
Construct with the given map.
|
| Modifier and Type | Method and Description |
|---|---|
MapBackedDataset<KEY,DATASET,INSTANCE> |
add(KEY key,
DATASET dataset)
Convenience method for populating a dataset by chaining method calls:
|
static <DATASET extends Dataset<INSTANCE> & Identifiable,INSTANCE> |
builder()
Returns a new builder.
|
Set<Map.Entry<KEY,DATASET>> |
entrySet() |
Set<KEY> |
getGroups()
Get the set of all defined group keys.
|
DATASET |
getInstances(KEY key)
Get sub-dataset corresponding to the given group key
|
Map<KEY,DATASET> |
getMap()
Get the underlying map.
|
INSTANCE |
getRandomInstance() |
INSTANCE |
getRandomInstance(KEY key)
Get a random instance from the sub-dataset corresponding to a specific
group.
|
Iterator<INSTANCE> |
iterator() |
int |
numInstances()
Returns the number of instances in this dataset.
|
static <INSTANCE,DATASET extends Dataset<INSTANCE> & Identifiable> |
of(Collection<DATASET> datasets)
Convenience method to construct a
MapBackedDataset from a number
of Identifiable sub-datasets. |
static <INSTANCE,DATASET extends Dataset<INSTANCE> & Identifiable> |
of(DATASET... datasets)
Convenience method to construct a
MapBackedDataset from a number
of Identifiable sub-datasets. |
static <INSTANCE,DATASET extends Dataset<INSTANCE> & Identifiable> |
of(DATASET d1)
Convenience method to construct a
MapBackedDataset from a number
of Identifiable sub-datasets. |
static <INSTANCE,DATASET extends Dataset<INSTANCE> & Identifiable> |
of(DATASET d1,
DATASET d2)
Convenience method to construct a
MapBackedDataset from a number
of Identifiable sub-datasets. |
static <INSTANCE,DATASET extends Dataset<INSTANCE> & Identifiable> |
of(DATASET d1,
DATASET d2,
DATASET d3)
Convenience method to construct a
MapBackedDataset from a number
of Identifiable sub-datasets. |
static <INSTANCE,DATASET extends Dataset<INSTANCE> & Identifiable> |
of(DATASET d1,
DATASET d2,
DATASET d3,
DATASET d4)
Convenience method to construct a
MapBackedDataset from a number
of Identifiable sub-datasets. |
static <INSTANCE,DATASET extends Dataset<INSTANCE> & Identifiable> |
of(DATASET d1,
DATASET d2,
DATASET d3,
DATASET d4,
DATASET d5)
Convenience method to construct a
MapBackedDataset from a number
of Identifiable sub-datasets. |
DATASET |
put(KEY key,
DATASET value) |
String |
toString() |
clear, clone, containsKey, containsValue, equals, get, hashCode, isEmpty, keySet, putAll, remove, size, valuesfinalize, getClass, notify, notifyAll, wait, wait, waitforEach, spliteratorclear, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, equals, forEach, get, getOrDefault, hashCode, isEmpty, keySet, merge, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, size, valuespublic MapBackedDataset()
MapBackedDataset backed by a HashMap.public MapBackedDataset(Map<KEY,DATASET> map)
map - the mappublic DATASET getInstances(KEY key)
GroupedDatasetgetInstances in interface GroupedDataset<KEY,DATASET extends Dataset<INSTANCE>,INSTANCE>key - the key.public Set<KEY> getGroups()
GroupedDatasetpublic INSTANCE getRandomInstance(KEY key)
GroupedDatasetgetRandomInstance in interface GroupedDataset<KEY,DATASET extends Dataset<INSTANCE>,INSTANCE>key - the group keypublic INSTANCE getRandomInstance()
getRandomInstance in interface Dataset<INSTANCE>public int numInstances()
DatasetnumInstances in interface Dataset<INSTANCE>public MapBackedDataset<KEY,DATASET,INSTANCE> add(KEY key, DATASET dataset)
final MapBackedDataset<String, ListDataset<String>, String> ds = new MapBackedDataset<String, ListDataset<String>, String>()
.add("A", new ListBackedDataset<String>())
.add("B", new ListBackedDataset<String>());
key - the key to insertdataset - the value to insert@SafeVarargs public static <INSTANCE,DATASET extends Dataset<INSTANCE> & Identifiable> MapBackedDataset<String,DATASET,INSTANCE> of(DATASET... datasets)
MapBackedDataset from a number
of Identifiable sub-datasets. Each sub-dataset becomes a group,
and the key is the identifier returned by Identifiable.getID().datasets - the datasets representing the groupspublic static <DATASET extends Dataset<INSTANCE> & Identifiable,INSTANCE> MapBackedDataset.IdentifiableBuilder<DATASET,INSTANCE> builder()
IdentifiableBuilder#IdentifiableBuilder()
constructor.public static <INSTANCE,DATASET extends Dataset<INSTANCE> & Identifiable> MapBackedDataset<String,DATASET,INSTANCE> of(DATASET d1)
MapBackedDataset from a number
of Identifiable sub-datasets. Each sub-dataset becomes a group,
and the key is the identifier returned by Identifiable.getID().d1 - first datasetpublic static <INSTANCE,DATASET extends Dataset<INSTANCE> & Identifiable> MapBackedDataset<String,DATASET,INSTANCE> of(DATASET d1, DATASET d2)
MapBackedDataset from a number
of Identifiable sub-datasets. Each sub-dataset becomes a group,
and the key is the identifier returned by Identifiable.getID().d1 - first datasetd2 - second datasetpublic static <INSTANCE,DATASET extends Dataset<INSTANCE> & Identifiable> MapBackedDataset<String,DATASET,INSTANCE> of(DATASET d1, DATASET d2, DATASET d3)
MapBackedDataset from a number
of Identifiable sub-datasets. Each sub-dataset becomes a group,
and the key is the identifier returned by Identifiable.getID().d1 - first datasetd2 - second datasetd3 - third datasetpublic static <INSTANCE,DATASET extends Dataset<INSTANCE> & Identifiable> MapBackedDataset<String,DATASET,INSTANCE> of(DATASET d1, DATASET d2, DATASET d3, DATASET d4)
MapBackedDataset from a number
of Identifiable sub-datasets. Each sub-dataset becomes a group,
and the key is the identifier returned by Identifiable.getID().d1 - first datasetd2 - second datasetd3 - third datasetd4 - forth datasetpublic static <INSTANCE,DATASET extends Dataset<INSTANCE> & Identifiable> MapBackedDataset<String,DATASET,INSTANCE> of(DATASET d1, DATASET d2, DATASET d3, DATASET d4, DATASET d5)
MapBackedDataset from a number
of Identifiable sub-datasets. Each sub-dataset becomes a group,
and the key is the identifier returned by Identifiable.getID().d1 - first datasetd2 - second datasetd3 - third datasetd4 - forth datasetd5 - fifth datasetpublic static <INSTANCE,DATASET extends Dataset<INSTANCE> & Identifiable> MapBackedDataset<String,DATASET,INSTANCE> of(Collection<DATASET> datasets)
MapBackedDataset from a number
of Identifiable sub-datasets. Each sub-dataset becomes a group,
and the key is the identifier returned by Identifiable.getID().datasets - the datasets representing the groups