Class MaxIntSet

java.lang.Object
it.unimi.di.prog2.h14.IntSet
it.unimi.di.prog2.h17.MaxIntSet
All Implemented Interfaces:
Iterable<Integer>

public class MaxIntSet extends IntSet
Esempio di MaxIntSet tratto dalla sezione 7.4 del libro di testo di Liskov et al..

Attenzione: questa classe estende IntSet che corrisponde all'implementazione di IntSet a cui รจ stato aggiunto un iteratore.

  • Field Details

    • biggest

      private int biggest
      The biggest element, if set is not empty
  • Constructor Details

    • MaxIntSet

      public MaxIntSet()
      Construct an empty MaxIntSet.
  • Method Details

    • insert

      public void insert(int x)
      Description copied from class: IntSet
      Adds the given element to this set.

      This method modifies the object, that is: \( S' = S \cup \{ x \} \).

      Overrides:
      insert in class IntSet
      Parameters:
      x - the element to be added.
    • remove

      public void remove(int x)
      Description copied from class: IntSet
      Removes the given element from this set.

      This method modifies the object, that is: \( S' = S \setminus \{ x \} \).

      Overrides:
      remove in class IntSet
      Parameters:
      x - the element to be removed.
    • max

      public int max() throws EmptyException
      Returns the maximum value in the set, or rises EmptyException otherwise.
      Returns:
      the maximum value in the set.
      Throws:
      EmptyException - if the set is empty.
    • repOk

      public boolean repOk()
    • toString

      public String toString()
      Overrides:
      toString in class IntSet