Package org.apache.uima.internal.util
Class IntBitSet
java.lang.Object
org.apache.uima.internal.util.IntBitSet
- All Implemented Interfaces:
PositiveIntSet
A set of non-zero positive ints.
This is better (size) than IntHashSet unless the expected max int to be contained is > size of
the set * 100 or you need to store negative ints
This impl is for use in a single thread case only
This impl supports offset, to let this bit set store items in a range n → n + small number
If using offset, you must add ints in a range equal to or above the offset
-
Field Summary
Fields inherited from interface org.apache.uima.internal.util.PositiveIntSet
IS_TRACE_MODE_SWITCH -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanadd(int original_key) voidAdd all elements of this bit set to the passed in IntVectorvoidclear()empty the IntBitSet. keeps the offsetbooleancontains(int key) intfind(int element) intget(int position) For FSBagIndex low level iterator use DOESN"T WORK WITH INCREMENTING position VALUESintintintintbooleanisValid(int position) This impl depends on position always pointing to a valid (== non 0) element of the set, when it should be validorg.apache.uima.internal.util.IntBitSet.IntBitSetIteratoriterator()intFor FSBagIndex low level iterator useintFor FSBagIndex low level iterator useintmoveToNext(int position) For FSBagIndex low level iterator useintmoveToPrevious(int position) For FSBagIndex low level iterator usebooleanremove(int original_key) intsize()int[]toString()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.uima.internal.util.PositiveIntSet
forAllInts
-
Constructor Details
-
IntBitSet
public IntBitSet()Construct an IntBitSet capable of holding ints from 0 to 63, (perhaps plus an offset) -
IntBitSet
public IntBitSet(int maxInt) Construct an IntBitSet capable of holding ints from 0 to maxInt (perhaps plus an offset)- Parameters:
maxInt- the biggest int (perhaps plus an offset) that can be held without growing the space
-
IntBitSet
public IntBitSet(int maxAdjKey, int offset)
-
-
Method Details
-
getOffset
public int getOffset()- Returns:
- the current offset
-
clear
public void clear()empty the IntBitSet. keeps the offset- Specified by:
clearin interfacePositiveIntSet
-
contains
public boolean contains(int key) - Specified by:
containsin interfacePositiveIntSet- Parameters:
key- - the integer (not adjusted for offset)- Returns:
- -
-
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.
-
add
public boolean add(int original_key) - Specified by:
addin interfacePositiveIntSet- Parameters:
original_key- - the int to add to the set- Returns:
- true if this set did not already contain the specified element
-
remove
public boolean remove(int original_key) - Specified by:
removein interfacePositiveIntSet- Parameters:
original_key- -- Returns:
- true if this key was removed, false if not present
-
size
public int size()- Specified by:
sizein interfacePositiveIntSet- Returns:
- the number of elements in this set
-
getSpaceUsed_in_bits_no_overhead
public int getSpaceUsed_in_bits_no_overhead() -
getSpaceUsed_in_words_no_overhead
public int getSpaceUsed_in_words_no_overhead()- Returns:
- space used in 32 bit words
-
getLargestMenber
public int getLargestMenber()- Returns:
- largest int in the set If the set has no members, 0 is returned
-
get
public int get(int position) Description copied from interface:PositiveIntSetFor FSBagIndex low level iterator use DOESN"T WORK WITH INCREMENTING position VALUES- Specified by:
getin interfacePositiveIntSet- Parameters:
position- - get the element at this position. This is for iterator use only, and is not related to any key- Returns:
- the element
-
iterator
public org.apache.uima.internal.util.IntBitSet.IntBitSetIterator 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) This impl depends on position always pointing to a valid (== non 0) element of the set, when it should be valid- Specified by:
isValidin interfacePositiveIntSet- Parameters:
position- -- Returns:
- true if the position is between the first and last element inclusive.
-
bulkAddTo
Add all elements of this bit set to the passed in IntVector- 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
-