Class SetInt

  • All Implemented Interfaces:
    java.io.Serializable

    public final class SetInt
    extends java.lang.Object
    implements java.io.Serializable
    Utility class to hold a set of ints Similar to a Set, but efficient for ints
    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor Description
      SetInt()
      Create a set of default size
      SetInt​(int initialCapacity)
      Create a set of given size
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean add​(int key)
      Add a value to the set
      void clear()
      clear all the entries
      boolean contains​(int key)
      Find a value from the set
      boolean isEmpty()
      is the set empty
      IteratorInt iterator()
      get an iterator to go through the set
      boolean remove​(int key)
      Remove a value from the set
      int size()
      get the number of used entries
      int[] toArray()
      convert to an array
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • SetInt

        public SetInt()
        Create a set of default size
      • SetInt

        public SetInt​(int initialCapacity)
        Create a set of given size
        Parameters:
        initialCapacity - in number of ints
    • Method Detail

      • add

        public boolean add​(int key)
        Add a value to the set
        Parameters:
        key - the value to add
        Returns:
        return true if added
      • remove

        public boolean remove​(int key)
        Remove a value from the set
        Parameters:
        key - the value to add
        Returns:
        return true if removed
      • contains

        public boolean contains​(int key)
        Find a value from the set
        Parameters:
        key - the value to find
        Returns:
        return true if found
      • size

        public int size()
        get the number of used entries
        Returns:
        the number of entries
      • isEmpty

        public boolean isEmpty()
        is the set empty
        Returns:
        true if empty
      • clear

        public void clear()
        clear all the entries
      • iterator

        public IteratorInt iterator()
        get an iterator to go through the set
        Returns:
        the iterator
      • toArray

        public int[] toArray()
        convert to an array
        Returns:
        a copy of the entries