T
- the type of items in the datasetpublic class ListBackedDataset<T> extends Object implements ListDataset<T>
ListBackedDataset
is a Dataset
backed by an ordered list of
items. For convenience, the dataset is itself presented as as list.Constructor and Description |
---|
ListBackedDataset()
Construct with the an empty
ArrayList as the backing store. |
ListBackedDataset(Iterable<T> iterator)
Construct by consuming the contents of the given iterator into the
backing list.
|
ListBackedDataset(List<T> backingList)
Construct with the given list of items.
|
Modifier and Type | Method and Description |
---|---|
void |
add(int index,
T element) |
boolean |
add(T e) |
boolean |
addAll(Collection<? extends T> c) |
boolean |
addAll(int index,
Collection<? extends T> c) |
void |
clear() |
boolean |
contains(Object o) |
boolean |
containsAll(Collection<?> c) |
T |
get(int index) |
T |
getInstance(int i)
Returns the instance at the specified position in this dataset.
|
List<T> |
getList()
Get the underlying list backing this dataset
|
T |
getRandomInstance() |
int |
indexOf(Object o) |
boolean |
isEmpty() |
Iterator<T> |
iterator() |
int |
lastIndexOf(Object o) |
ListIterator<T> |
listIterator() |
ListIterator<T> |
listIterator(int index) |
int |
numInstances()
Returns the number of instances in this dataset.
|
T |
remove(int index) |
boolean |
remove(Object o) |
boolean |
removeAll(Collection<?> c) |
boolean |
retainAll(Collection<?> c) |
T |
set(int index,
T element) |
int |
size() |
List<T> |
subList(int fromIndex,
int toIndex) |
Object[] |
toArray() |
<V> V[] |
toArray(V[] a) |
String |
toString() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
equals, hashCode, replaceAll, sort, spliterator
parallelStream, removeIf, stream
public ListBackedDataset()
ArrayList
as the backing store.public ListBackedDataset(List<T> backingList)
backingList
- the backing listpublic ListBackedDataset(Iterable<T> iterator)
Obviously this method could cause problems if the number of items in the iterator is very large, as memory could be exhausted. Care should be taken.
iterator
- the data to readpublic T getRandomInstance()
getRandomInstance
in interface Dataset<T>
public final int size()
public int numInstances()
Dataset
numInstances
in interface Dataset<T>
public T getInstance(int i)
ListDataset
getInstance
in interface ListDataset<T>
i
- index of the instance to returnpublic List<T> getList()
public boolean isEmpty()
public <V> V[] toArray(V[] a)
public boolean containsAll(Collection<?> c)
containsAll
in interface Collection<T>
containsAll
in interface List<T>
public boolean addAll(Collection<? extends T> c)
public boolean addAll(int index, Collection<? extends T> c)
public boolean removeAll(Collection<?> c)
public boolean retainAll(Collection<?> c)
public void clear()
public int lastIndexOf(Object o)
lastIndexOf
in interface List<T>
public ListIterator<T> listIterator()
listIterator
in interface List<T>
public ListIterator<T> listIterator(int index)
listIterator
in interface List<T>