Class DiscreteSet<E>

java.lang.Object
org.episteme.core.mathematics.structures.sets.DiscreteSet<E>
All Implemented Interfaces:
Iterable<E>, FiniteSet<E>, Set<E>

public final class DiscreteSet<E> extends Object implements FiniteSet<E>
Implementation of a finite set using a backing java.util.Set.
Since:
1.1
Author:
Silvere Martin-Michiellot, Gemini AI (Google DeepMind)
  • Constructor Details

    • DiscreteSet

      public DiscreteSet(Set<E> elements)
      Constructs a set containing the specified elements.
      Parameters:
      elements - the elements
    • DiscreteSet

      public DiscreteSet(E element)
      Constructs a set containing a single element.
      Parameters:
      element - the element
  • Method Details

    • getElements

      public Set<E> getElements()
      Returns an unmodifiable view of the elements in this set.
      Returns:
      the elements
    • size

      public long size()
      Description copied from interface: FiniteSet
      Returns the number of elements in this set (its cardinality).
      Specified by:
      size in interface FiniteSet<E>
      Returns:
      the cardinality of this set
    • contains

      public boolean contains(E element)
      Description copied from interface: Set
      Tests whether this set contains the specified element.

      This is the fundamental operation of a set - membership testing.

      Specified by:
      contains in interface Set<E>
      Parameters:
      element - the element to test for membership
      Returns:
      true if this set contains the element, false otherwise
      See Also:
    • isEmpty

      public boolean isEmpty()
      Description copied from interface: Set
      Returns true if this set contains no elements.

      The empty set (∅) is a fundamental concept in set theory. It is the unique set containing no elements.

      Specified by:
      isEmpty in interface Set<E>
      Returns:
      true if this set is empty
    • iterator

      public Iterator<E> iterator()
      Description copied from interface: FiniteSet
      Returns an iterator over the elements in this set.
      Specified by:
      iterator in interface FiniteSet<E>
      Specified by:
      iterator in interface Iterable<E>
      Returns:
      an iterator over the elements in this set
    • description

      public String description()
      Description copied from interface: Set
      Returns a human-readable description of this set.

      Examples:

      • "ℝ (Real Numbers)"
      • "ℤ/12ℤ (Integers modulo 12)"
      • "{1, 2, 3, 4, 5}"

      Specified by:
      description in interface Set<E>
      Returns:
      a description of this set
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object