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 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
-
-
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 boolean
add(int original_key)
void
bulkAddTo(IntVector v)
Add all elements of this bit set to the passed in IntVectorvoid
clear()
empty the IntBitSet.boolean
contains(int key)
int
find(int element)
int
get(int position)
For FSBagIndex low level iterator use DOESN"T WORK WITH INCREMENTING position VALUESint
getLargestMenber()
int
getOffset()
int
getSpaceUsed_in_bits_no_overhead()
int
getSpaceUsed_in_words_no_overhead()
boolean
isValid(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.IntBitSetIterator
iterator()
int
moveToFirst()
For FSBagIndex low level iterator useint
moveToLast()
For FSBagIndex low level iterator useint
moveToNext(int position)
For FSBagIndex low level iterator useint
moveToPrevious(int position)
For FSBagIndex low level iterator useboolean
remove(int original_key)
int
size()
int[]
toIntArray()
String
toString()
-
-
-
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:
clear
in interfacePositiveIntSet
-
contains
public boolean contains(int key)
- Specified by:
contains
in interfacePositiveIntSet
- Parameters:
key
- - the integer (not adjusted for offset)- Returns:
- -
-
find
public int find(int element)
- Specified by:
find
in 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:
add
in 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:
remove
in interfacePositiveIntSet
- Parameters:
original_key
- -- Returns:
- true if this key was removed, false if not present
-
size
public int size()
- Specified by:
size
in 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:PositiveIntSet
For FSBagIndex low level iterator use DOESN"T WORK WITH INCREMENTING position VALUES- Specified by:
get
in 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:
iterator
in interfacePositiveIntSet
- Returns:
- an iterator (may be ordered or unordered) over the members of the set
-
moveToFirst
public int moveToFirst()
Description copied from interface:PositiveIntSet
For FSBagIndex low level iterator use- Specified by:
moveToFirst
in interfacePositiveIntSet
- Returns:
- the position of the first element, or -1;
-
moveToLast
public int moveToLast()
Description copied from interface:PositiveIntSet
For FSBagIndex low level iterator use- Specified by:
moveToLast
in interfacePositiveIntSet
- Returns:
- the position of the last element, or -1;
-
moveToNext
public int moveToNext(int position)
Description copied from interface:PositiveIntSet
For FSBagIndex low level iterator use- Specified by:
moveToNext
in interfacePositiveIntSet
- Parameters:
position
- -- Returns:
- the position of the next element, or -1;
-
moveToPrevious
public int moveToPrevious(int position)
Description copied from interface:PositiveIntSet
For FSBagIndex low level iterator use- Specified by:
moveToPrevious
in 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:
isValid
in 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:
bulkAddTo
in interfacePositiveIntSet
- Parameters:
v
- - to be added to
-
toIntArray
public int[] toIntArray()
- Specified by:
toIntArray
in interfacePositiveIntSet
- Returns:
- the set as an arbitrarily ordered int array
-
-