Class IntPresentSet


  • public class IntPresentSet
    extends java.lang.Object
    This is a set of ints. This class provides methods to insert an int, check for the presence of a given int, and remove an int from the set. This class is designed to use as little RAM as possible, and assumes that the ints are reasonably closely-spaced. In the case where the ints are consecutive, this class will use not much more than an eighth of a byte per mapping.
    Author:
    Matthew Wakeling
    • Constructor Summary

      Constructors 
      Constructor Description
      IntPresentSet()
      Constructor for this class.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void add​(java.lang.Integer i)
      Adds an int to the set.
      void clear()
      Removes all ints from the object.
      boolean contains​(int i)
      Returns whether the given int is present in this set.
      boolean contains​(java.lang.Integer i)
      Returns whether the given Integer is present in this set.
      void set​(int i, boolean newBit)
      Adds the given int to the set.
      int size()
      Returns the number of ints present.
      java.lang.String toString()
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • IntPresentSet

        public IntPresentSet()
        Constructor for this class. Creates an empty map.
    • Method Detail

      • set

        public void set​(int i,
                        boolean newBit)
        Adds the given int to the set.
        Parameters:
        i - the int to add to the set
        newBit - true to add to the set, false to remove from the set
      • contains

        public boolean contains​(int i)
        Returns whether the given int is present in this set.
        Parameters:
        i - any int
        Returns:
        true or false
      • add

        public void add​(java.lang.Integer i)
        Adds an int to the set.
        Parameters:
        i - an Integer
      • contains

        public boolean contains​(java.lang.Integer i)
        Returns whether the given Integer is present in this set.
        Parameters:
        i - any Integer
        Returns:
        true or false
      • size

        public int size()
        Returns the number of ints present.
        Returns:
        the size
      • clear

        public void clear()
        Removes all ints from the object.
      • toString

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