Package org.scijava.object
Class SortedObjectIndex<E extends Comparable<? super E>>
- java.lang.Object
-
- org.scijava.object.ObjectIndex<E>
-
- org.scijava.object.SortedObjectIndex<E>
-
- All Implemented Interfaces:
Iterable<E>,Collection<E>
- Direct Known Subclasses:
ModuleIndex,PluginIndex,ServiceIndex
public class SortedObjectIndex<E extends Comparable<? super E>> extends ObjectIndex<E>
Data structure for managing sorted lists of registered objects.This data structure is the same as a vanilla
ObjectIndexexcept that each type list is kept in sorted order; hence, the items managed must implement theComparableinterface. When adding a single item (i.e., withObjectIndex.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., withaddAll(Collection)), the items are appended and the list is then resorted (O(n log n) time for all items).- Author:
- Curtis Rueden
-
-
Field Summary
-
Fields inherited from class org.scijava.object.ObjectIndex
hoard
-
-
Constructor Summary
Constructors Constructor Description SortedObjectIndex(Class<E> baseClass)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanaddAll(Collection<? extends E> c)protected booleanaddToList(E obj, List<E> list, boolean batch)booleancontains(Object o)booleancontainsAll(Collection<?> c)-
Methods inherited from class org.scijava.object.ObjectIndex
add, add, add, addLater, clear, get, getAll, getBaseClass, getType, getTypes, isEmpty, iterator, remove, remove, remove, removeAll, removeFromList, retainAll, retrieveList, retrieveListsForType, size, toArray, toArray, toString
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Collection
equals, hashCode, parallelStream, removeIf, spliterator, stream
-
-
-
-
Method Detail
-
contains
public boolean contains(Object o)
- Specified by:
containsin interfaceCollection<E extends Comparable<? super E>>- Overrides:
containsin classObjectIndex<E extends Comparable<? super E>>
-
containsAll
public boolean containsAll(Collection<?> c)
- Specified by:
containsAllin interfaceCollection<E extends Comparable<? super E>>- Overrides:
containsAllin classObjectIndex<E extends Comparable<? super E>>
-
addAll
public boolean addAll(Collection<? extends E> c)
- Specified by:
addAllin interfaceCollection<E extends Comparable<? super E>>- Overrides:
addAllin classObjectIndex<E extends Comparable<? super E>>
-
addToList
protected boolean addToList(E obj, List<E> list, boolean batch)
- Overrides:
addToListin classObjectIndex<E extends Comparable<? super E>>
-
-