Package org.apache.uima.internal.util
Class IntBitSet
- java.lang.Object
-
- org.apache.uima.internal.util.IntBitSet
-
- All Implemented Interfaces:
PositiveIntSet
public class IntBitSet extends java.lang.Object implements 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
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private classIntBitSet.IntBitSetIterator
-
Field Summary
Fields Modifier and Type Field Description private intoffsetprivate java.util.BitSetsetprivate intsize-
Fields inherited from interface org.apache.uima.internal.util.PositiveIntSet
IS_TRACE_MODE_SWITCH
-
-
Constructor Summary
Constructors Constructor Description IntBitSet()Construct an IntBitSet capable of holding ints from 0 to 63, (perhaps plus an offset)IntBitSet(int maxInt)Construct an IntBitSet capable of holding ints from 0 to maxInt (perhaps plus an offset)IntBitSet(int maxAdjKey, int offset)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanadd(int original_key)voidbulkAddTo(IntVector v)Add all elements of this bit set to the passed in IntVectorvoidclear()empty the IntBitSet.booleancontains(int key)intfind(int element)intget(int position)For FSBagIndex low level iterator use DOESN"T WORK WITH INCREMENTING position VALUESintgetLargestMenber()intgetOffset()intgetSpaceUsed_in_bits_no_overhead()intgetSpaceUsed_in_words_no_overhead()booleanisValid(int position)This impl depends on position always pointing to a valid (== non 0) element of the set, when it should be validIntBitSet.IntBitSetIteratoriterator()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 original_key)intsize()int[]toIntArray()java.lang.StringtoString()-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.apache.uima.internal.util.PositiveIntSet
forAllInts
-
-
-
-
Constructor Detail
-
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 Detail
-
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 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
public void bulkAddTo(IntVector v)
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
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-