Package org.apache.uima.internal.util
Class IntSet
- java.lang.Object
-
- org.apache.uima.internal.util.IntSet
-
- All Implemented Interfaces:
PositiveIntSet
public class IntSet extends java.lang.Object implements PositiveIntSet
This class implements a set of integers. It does not implement theSetinterface for performance reasons, though methods with the same name are equivalent. This does not implement shorts + offset, like the IntHashSet does because by the time that might be of interest, we would switch to IntHashSet to get ~O(1) operations including contains.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private classIntSet.IntSetIterator
-
Field Summary
Fields Modifier and Type Field Description private IntVectoriVecThe data.-
Fields inherited from interface org.apache.uima.internal.util.PositiveIntSet
IS_TRACE_MODE_SWITCH
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanadd(int element)Adds the specified int to this set.voidbulkAddTo(IntVector v)add all elements in this set to the IntVector v as a bulk operationvoidclear()remove all members of the setbooleancontains(int element)Tests if this set contains the specified element.booleanequals(java.lang.Object o)Tests if two sets are equal.intfind(int element)intget(int n)Used for FsBagIndex, and internally to compute most positive/neginthashCode()intindexOf(int element)booleanisValid(int position)For FSBagIndex low level iterator useIntSet.IntSetIteratoriterator()intmoveToFirst()For FSBagIndex low level iterator useintmoveToLast()For FSBagIndex low level iterator useintmoveToNext(int position)For FSBagIndex low level iterator useintmoveToPrevious(int position)For FSBagIndex low level iterator usebooleanremove(int key)voidremoveElementAt(int n)Removes then-th element in this set.intsize()int[]toIntArray()java.lang.StringtoString()-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.apache.uima.internal.util.PositiveIntSet
forAllInts
-
-
-
-
Field Detail
-
iVec
private IntVector iVec
The data.
-
-
Method Detail
-
add
public boolean add(int element)
Adds the specified int to this set.- Specified by:
addin interfacePositiveIntSet- Parameters:
element- the integer to be added.- Returns:
trueif this set did not already contain this element,falseotherwise.
-
contains
public boolean contains(int element)
Tests if this set contains the specified element.- Specified by:
containsin interfacePositiveIntSet- Parameters:
element- the element to be tested.- Returns:
trueif the element is contained in this set,falseotherwise.
-
find
public int find(int element)
- Specified by:
findin interfacePositiveIntSet- Parameters:
element- an item which may be in the set- Returns:
- -1 if the item is not in the set, or a position value that can be used with iterators to start at that item.
-
size
public int size()
- Specified by:
sizein interfacePositiveIntSet- Returns:
- the size of this set.
-
get
public int get(int n)
Used for FsBagIndex, and internally to compute most positive/neg- Specified by:
getin interfacePositiveIntSet- Parameters:
n- the position- Returns:
- the value at that position
-
removeElementAt
public void removeElementAt(int n)
Removes then-th element in this set.- Parameters:
n- -
-
equals
public boolean equals(java.lang.Object o)
Tests if two sets are equal. This is the case if the two sets are of the same size, and every element in one set in contained in the other set.
Note that in order to increase performance, before the sets are actually compared the way described above, the sums of the elements in both sets are calculated, ignoring possible int overflows. If the sums are not equal, the two sets cannot be equal. In case the sums are equal, the two sets are compared element by element.- Overrides:
equalsin classjava.lang.Object- Parameters:
o- the set to be tested for equality with this set.- Returns:
trueif the sets are equal,falseotherwise.
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
indexOf
public int indexOf(int element)
-
clear
public void clear()
Description copied from interface:PositiveIntSetremove all members of the set- Specified by:
clearin interfacePositiveIntSet
-
remove
public boolean remove(int key)
- Specified by:
removein interfacePositiveIntSet- Parameters:
key- -- Returns:
- true if the set had this element before the remove
-
iterator
public IntSet.IntSetIterator iterator()
- Specified by:
iteratorin interfacePositiveIntSet- Returns:
- an iterator (may be ordered or unordered) over the members of the set
-
moveToFirst
public int moveToFirst()
Description copied from interface:PositiveIntSetFor FSBagIndex low level iterator use- Specified by:
moveToFirstin interfacePositiveIntSet- Returns:
- the position of the first element, or -1;
-
moveToLast
public int moveToLast()
Description copied from interface:PositiveIntSetFor FSBagIndex low level iterator use- Specified by:
moveToLastin interfacePositiveIntSet- Returns:
- the position of the last element, or -1;
-
moveToNext
public int moveToNext(int position)
Description copied from interface:PositiveIntSetFor FSBagIndex low level iterator use- Specified by:
moveToNextin interfacePositiveIntSet- Parameters:
position- -- Returns:
- the position of the next element, or -1;
-
moveToPrevious
public int moveToPrevious(int position)
Description copied from interface:PositiveIntSetFor FSBagIndex low level iterator use- Specified by:
moveToPreviousin interfacePositiveIntSet- Parameters:
position- -- Returns:
- the position of the next element, or -1;
-
isValid
public boolean isValid(int position)
Description copied from interface:PositiveIntSetFor FSBagIndex low level iterator use- Specified by:
isValidin interfacePositiveIntSet- Parameters:
position- -- Returns:
- true if the position is between the first and last element inclusive.
-
bulkAddTo
public void bulkAddTo(IntVector v)
Description copied from interface:PositiveIntSetadd all elements in this set to the IntVector v as a bulk operation- Specified by:
bulkAddToin interfacePositiveIntSet- Parameters:
v- - to be added to
-
toIntArray
public int[] toIntArray()
- Specified by:
toIntArrayin interfacePositiveIntSet- Returns:
- the set as an arbitrarily ordered int array
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-