Package org.apache.uima.internal.util
Class OrderedFsSet_array<T extends FeatureStructure>
java.lang.Object
org.apache.uima.internal.util.OrderedFsSet_array<T>
- All Implemented Interfaces:
- Iterable<T>
This one is being used, the other one (ending in 2) may be put back into service for large sizes,
 later. (7/2017)
 
 
 A set of FSs, ordered using a comparator Not thread-safe, use on single thread only
 
 Use: set-sorted indexes in UIMA
 
 Entries kept in order in 1 big TOP[]
   have ensureCapacity - grows by doubling up to multiplication-limit point, then by addition
 
 Adds optimized:
   - maintain high mark, if >, add to end
 
 shifting optimization:
   for removes: shift space to back or front, whichever is closer 
   for adds: shift space from back or front, whichever is closer
- 
Constructor SummaryConstructorsConstructorDescriptionOrderedFsSet_array(Comparator<TOP> comparatorNoTypeWithID, Comparator<TOP> comparatorNoTypeWithoutID) OrderedFsSet_array(OrderedFsSet_array<T> set, boolean isReadOnly) called to make a read-only copy
- 
Method SummaryModifier and TypeMethodDescriptionbooleanbooleanadd(T fs1, Comparator<TOP> comparator) intbinarySearch(TOP[] _a, int start, int end, TOP fs, Comparator<TOP> _comparatorWithID) intbinarySearchLeftMostEqual(TOP fs, int start, int end, Comparator<TOP> comparator) Guaranteed by caller to have an equal (withoutID) item, but might be the "end" item searching up to find it.voidclear()intfind(TOP fs, Comparator<TOP> comparator) intfindWithoutID(TOP fs) using NoType because all callers of this have already used the type of fs to select the right index.getAtPos(int pos) booleanisEmpty()iterator()booleanRemoves the exactly matching (including ID) FS if present Only called when type of FS matches this index's type, so the NoType comparator is used.intsize()TOP[]toArray()<U> U[]toArray(U[] a1) toString()Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.IterableforEach, spliterator
- 
Constructor Details- 
OrderedFsSet_arraypublic OrderedFsSet_array(Comparator<TOP> comparatorNoTypeWithID, Comparator<TOP> comparatorNoTypeWithoutID) 
- 
OrderedFsSet_arraycalled to make a read-only copy- Parameters:
- set- -
- isReadOnly- -
 
 
- 
- 
Method Details- 
sizepublic int size()
- 
isEmptypublic boolean isEmpty()
- 
add
- 
add- Parameters:
- fs1- item to add
- comparator- either the comparator without type with ID for sorted indexes, or the comparator withoutType without ID for set indexes
- Returns:
- true if fs was added (not already present)
 
- 
findWithoutIDusing NoType because all callers of this have already used the type of fs to select the right index.- Parameters:
- fs- -
- Returns:
- -
 
- 
find
- 
binarySearch- Parameters:
- _a- the array
- start- the index representing the lower bound (inclusive) to search for
- end- the index representing the upper bound (exclusive) to search for
- fs- - the fs to search for
- _comparatorWithID- -
- Returns:
- - the index of the found item, or if not found, the (-index) -1 of the position one more than where the item would go
 
- 
removeRemoves the exactly matching (including ID) FS if present Only called when type of FS matches this index's type, so the NoType comparator is used.- Parameters:
- o- the object (must be a FS of the type of this index) to remove
- Returns:
- true if it was removed, false if it wasn't in the index
 
- 
clearpublic void clear()- See Also:
 
- 
binarySearchLeftMostEqualGuaranteed by caller to have an equal (withoutID) item, but might be the "end" item searching up to find it.- Parameters:
- fs- - the fs to search for
- start- the index representing the lower bound (inclusive) to search for
- end- the index representing the upper bound (exclusive) to search for Not called unless there's one equal item below this.
- comparator- the comparator to use (with or without type)
- Returns:
- - the index of the leftmost equal (without id) item
 
- 
iterator- Specified by:
- iteratorin interface- Iterable<T extends FeatureStructure>
 
- 
toArray
- 
toArraypublic <U> U[] toArray(U[] a1) 
- 
getAtPos
- 
toString
 
-