Class 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
    • 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 IntVector
      void 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 VALUES
      int 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 valid
      org.apache.uima.internal.util.IntBitSet.IntBitSetIterator iterator()  
      int moveToFirst()
      For FSBagIndex low level iterator use
      int moveToLast()
      For FSBagIndex low level iterator use
      int moveToNext​(int position)
      For FSBagIndex low level iterator use
      int moveToPrevious​(int position)
      For FSBagIndex low level iterator use
      boolean remove​(int original_key)  
      int size()  
      int[] toIntArray()  
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • 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 interface PositiveIntSet
      • contains

        public boolean contains​(int key)
        Specified by:
        contains in interface PositiveIntSet
        Parameters:
        key - - the integer (not adjusted for offset)
        Returns:
        -
      • find

        public int find​(int element)
        Specified by:
        find in interface PositiveIntSet
        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 interface PositiveIntSet
        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 interface PositiveIntSet
        Parameters:
        original_key - -
        Returns:
        true if this key was removed, false if not present
      • size

        public int size()
        Specified by:
        size in interface PositiveIntSet
        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 interface PositiveIntSet
        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 interface PositiveIntSet
        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 interface PositiveIntSet
        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 interface PositiveIntSet
        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 interface PositiveIntSet
        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 interface PositiveIntSet
        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 interface PositiveIntSet
        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 interface PositiveIntSet
        Parameters:
        v - - to be added to
      • toIntArray

        public int[] toIntArray()
        Specified by:
        toIntArray in interface PositiveIntSet
        Returns:
        the set as an arbitrarily ordered int array
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object