Interface ISet

    • Method Detail

      • iterator

        ISetIterator iterator()
        Use the following loop to iterate over this set without autoboxing. // more readable but with autoboxing for(int value:set){ ... } // more verbose but without autoboxing ISetIterator iter = set.primitiveIterator(); while(iter.hasNext()){ int k = iter.next(); ... } Do not use this iterator to make nested loops over ISet (prefer newIterator())
        Specified by:
        iterator in interface Iterable<Integer>
        Returns:
        the default iterator (singleton) of this set
      • newIterator

        ISetIterator newIterator()
        Creates a new iterator object, for nested loops only.
        Returns:
        a new iterator for this set
      • add

        boolean add​(int element)
        Add element to the set
        Parameters:
        element - element to add
        Returns:
        true iff element was not in the set and has been added
      • remove

        boolean remove​(int element)
        Remove the first occurrence of element from the set
        Parameters:
        element - element to add
        Returns:
        true iff element was in the set and has been removed
      • contains

        boolean contains​(int element)
        Test the existence of element in the set
        Parameters:
        element - element to add
        Returns:
        true iff the set contains element
      • isEmpty

        default boolean isEmpty()
        Returns:
        true iff the set is empty
      • size

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

        void clear()
        Remove all elements from the set
      • min

        int min()
        Returns:
        the smallest element in the set throws an exception if the set is empty Time complexity is linear for BIPARTITESET and LINKED_LIST (constant time otherwise)
      • max

        int max()
        Returns:
        the largest element in the set throws an exception if the set is empty Time complexity is linear for BIPARTITESET and LINKED_LIST (constant time otherwise)
      • getSetType

        SetType getSetType()
        Returns:
        the implementation type of this set
      • toArray

        default int[] toArray()
        Copies the set in an array if integers
        Returns:
        an array containing every integer of the set