Interface ReadOnlySet<E>

Type Parameters:
E - the element type
All Superinterfaces:
Iterable<E>, ReadOnlyCollection<E>
All Known Subinterfaces:
ImmutableNavigableSet<E>, ImmutableSequencedSet<E>, ImmutableSet<E>, ImmutableSortedSet<E>, ReadOnlyNavigableSet<E>, ReadOnlySequencedSet<E>, ReadOnlySortedSet<E>
All Known Implementing Classes:
org.jhotdraw8.icollection.impl.champ.AbstractMutableChampSet, AbstractReadOnlySet, ChampSet, ChampVectorSet, ImmutableSetFacade, MutableChampSet, MutableChampVectorSet, MutableRedBlackSet, MutableSetFacade, NavigableSetFacade, ReadOnlyNavigableSetFacade, ReadOnlySequencedSetFacade, ReadOnlySetFacade, ReadOnlySortedSetFacade, RedBlackSet, SequencedSetFacade, SetFacade

public interface ReadOnlySet<E> extends ReadOnlyCollection<E>
A read-only interface to a set. A set is a collection that contains no duplicate elements.

This interface does not guarantee 'read-only', it actually guarantees 'readable'. We use the prefix 'ReadOnly' because this is the naming convention in JavaFX for interfaces that provide read methods but no write methods.

  • Method Details

    • iteratorToHashCode

      static <E> int iteratorToHashCode(@NonNull Iterator<E> iterator)
      Returns the sum of the hash codes of all elements in the provided iterator.
      Type Parameters:
      E - the element type
      Parameters:
      iterator - an iterator
      Returns:
      the sum of the hash codes of the elements
      See Also:
    • setEquals

      static <E> boolean setEquals(@NonNull ReadOnlySet<E> set, @Nullable Object o)
      Compares a read-only set with an object for equality. Returns true if the given object is also a read-only set and the two sets contain the same elements.
      Type Parameters:
      E - the element type
      Parameters:
      set - a set
      o - an object
      Returns:
      true if the object is equal to the set
    • asSet

      default @NonNull Set<E> asSet()
      Wraps this set in the Set interface - without copying.
      Returns:
      the wrapped set
    • equals

      boolean equals(@Nullable Object o)
      Compares the specified object with this set for equality.

      Returns true if the given object is also a read-only set and the two sets contain the same elements, ignoring the sequence of the elements.

      Implementations of this method should use setEquals(org.jhotdraw8.icollection.readonly.ReadOnlySet<E>, java.lang.Object).

      Overrides:
      equals in class Object
      Parameters:
      o - an object
      Returns:
      true if the object is equal to this map
    • hashCode

      int hashCode()
      Returns the hash code value for this set. The hash code is the sum of the hash code of its elements.

      Implementations of this method should use iteratorToHashCode(java.util.Iterator<E>).

      Overrides:
      hashCode in class Object
      Returns:
      the hash code value for this set
      See Also:
    • characteristics

      default int characteristics()
      Returns the Spliterator characteristics of this collection.

      The default implementation returns Spliterator.SIZED| Spliterator.DISTINCT.

      Specified by:
      characteristics in interface ReadOnlyCollection<E>
      Returns:
      the characteristics