Interface IntSet

  • All Known Implementing Classes:
    AbstractIntSet, ArrayIntSet, BitIntSet, ShiftedBitIntSet

    public interface IntSet

    Description: An interface describing a set of primitive integers. An implementation may only accept certain types of integers (e.g. only positive integers).

    Copyright: Copyright (c) 2007

    Company: Clark & Parsia, LLC.

    Author:
    Evren Sirin
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      void add​(int value)
      Adds a new integer to this set.
      void addAll​(IntSet other)
      Adds all the integers from another set to this set.
      boolean contains​(int value)
      Checks if the given integer value is in this set.
      IntSet copy()
      Creates a copy of this set.
      boolean isEmpty()
      Cehcks if the set is empty.
      IntIterator iterator()
      An iterator over the values of this set.
      int max()
      Returns the maximum integer in this set.
      int min()
      Returns the minimum integer in this set.
      void remove​(int value)
      Remove the given integer value from this set.
      int size()
      Returns the number of elements in the set.
      IntSet union​(IntSet set)
      Creates a new IntSet that is the union of this set and the given set.
    • Method Detail

      • add

        void add​(int value)
          throws java.lang.IllegalArgumentException
        Adds a new integer to this set.
        Parameters:
        value - integer value to be added
        Throws:
        java.lang.IllegalArgumentException - if the value is not supported by this set implementation
      • addAll

        void addAll​(IntSet other)
        Adds all the integers from another set to this set.
        Parameters:
        other - the set whose elements will be added
        Throws:
        java.lang.IllegalArgumentException - if any of the values in the other set is not supported by this set implementation
      • contains

        boolean contains​(int value)
        Checks if the given integer value is in this set.
        Parameters:
        value - the integer value being checked
        Returns:
        true if the value is in this set
      • copy

        IntSet copy()
        Creates a copy of this set.
        Returns:
        a copy of this set
      • isEmpty

        boolean isEmpty()
        Cehcks if the set is empty.
        Returns:
        true if there are no elements in the set
      • iterator

        IntIterator iterator()
        An iterator over the values of this set. There is no guarantee on the _order of the elements.
        Returns:
        an iterator over the values of the set
      • max

        int max()
         throws java.util.NoSuchElementException
        Returns the maximum integer in this set.
        Returns:
        the maximum integer in this set
        Throws:
        java.util.NoSuchElementException - if the set is empty
      • min

        int min()
        Returns the minimum integer in this set.
        Returns:
        the minimum integer in this set
        Throws:
        java.util.NoSuchElementException - if the set is empty
      • remove

        void remove​(int value)
        Remove the given integer value from this set.
        Parameters:
        value - the integer value to be removed
      • union

        IntSet union​(IntSet set)
        Creates a new IntSet that is the union of this set and the given set. Neither of the sets are changed by this operation.
        Parameters:
        set - the other set that will be included in the union result
        Returns:
        a new IntSet instance that is the union of two sets
      • size

        int size()
        Returns the number of elements in the set.
        Returns:
        the number of elements in the set