org.scijava.object
Class SortedObjectIndex<E extends Comparable<? super E>>

java.lang.Object
  extended by org.scijava.object.ObjectIndex<E>
      extended by 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 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).

Author:
Curtis Rueden

Field Summary
 
Fields inherited from class org.scijava.object.ObjectIndex
hoard
 
Constructor Summary
SortedObjectIndex(Class<E> baseClass)
           
 
Method Summary
 boolean addAll(Collection<? extends E> c)
           
protected  boolean addToList(E obj, List<E> list, boolean batch)
           
 boolean contains(Object o)
           
 boolean containsAll(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
 

Constructor Detail

SortedObjectIndex

public SortedObjectIndex(Class<E> baseClass)
Method Detail

contains

public boolean contains(Object o)
Specified by:
contains in interface Collection<E extends Comparable<? super E>>
Overrides:
contains in class ObjectIndex<E extends Comparable<? super E>>

containsAll

public boolean containsAll(Collection<?> c)
Specified by:
containsAll in interface Collection<E extends Comparable<? super E>>
Overrides:
containsAll in class ObjectIndex<E extends Comparable<? super E>>

addAll

public boolean addAll(Collection<? extends E> c)
Specified by:
addAll in interface Collection<E extends Comparable<? super E>>
Overrides:
addAll in class ObjectIndex<E extends Comparable<? super E>>

addToList

protected boolean addToList(E obj,
                            List<E> list,
                            boolean batch)
Overrides:
addToList in class ObjectIndex<E extends Comparable<? super E>>


Copyright © 2009–2014 SciJava. All rights reserved.