public class SortedObjectIndex<E extends Comparable<? super E>> extends ObjectIndex<E>
This data structure is the same as a vanilla ObjectIndex
except that
each type list is kept in sorted order; hence, the items managed must
implement the Comparable
interface. When adding a single item (i.e.,
with ObjectIndex.add(Object)
), a binary search is used to insert it in the
correct position (O(log n) + O(n) time per item). When adding multiple items
at once (i.e., with addAll(Collection)
), the items are appended and
the list is then resorted (O(n log n) time for all items).
hoard
Constructor and Description |
---|
SortedObjectIndex(Class<E> baseClass) |
Modifier and Type | Method and Description |
---|---|
boolean |
addAll(Collection<? extends E> c) |
protected boolean |
addToList(E obj,
List<E> list,
boolean batch) |
boolean |
contains(Object o) |
boolean |
containsAll(Collection<?> c) |
add, add, add, addLater, clear, get, getAll, getBaseClass, getType, getTypes, isEmpty, iterator, remove, remove, remove, removeAll, removeFromList, retainAll, retrieveList, retrieveListsForType, size, toArray, toArray, toString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
equals, hashCode, parallelStream, removeIf, spliterator, stream
public boolean contains(Object o)
contains
in interface Collection<E extends Comparable<? super E>>
contains
in class ObjectIndex<E extends Comparable<? super E>>
public boolean containsAll(Collection<?> c)
containsAll
in interface Collection<E extends Comparable<? super E>>
containsAll
in class ObjectIndex<E extends Comparable<? super E>>
public boolean addAll(Collection<? extends E> c)
addAll
in interface Collection<E extends Comparable<? super E>>
addAll
in class ObjectIndex<E extends Comparable<? super E>>
protected boolean addToList(E obj, List<E> list, boolean batch)
addToList
in class ObjectIndex<E extends Comparable<? super E>>
Copyright © 2015–2022 SciJava. All rights reserved.