Module org.jhotdraw8.icollection
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
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 Summary
Modifier and TypeMethodDescriptionasSet()Wraps this set in the Set interface - without copying.default intReturns the Spliterator characteristics of this collection.booleanCompares the specified object with this set for equality.inthashCode()Returns the hash code value for this set.static <E> intiteratorToHashCode(@NonNull Iterator<E> iterator) Returns the sum of the hash codes of all elements in the provided iterator.static <E> booleansetEquals(@NonNull ReadOnlySet<E> set, @Nullable Object o) Compares a read-only set with an object for equality.Methods inherited from interface java.lang.Iterable
forEach, spliteratorMethods inherited from interface org.jhotdraw8.icollection.readonly.ReadOnlyCollection
asCollection, contains, containsAll, isEmpty, iterator, size, stream, toArray, toArray
-
Method Details
-
iteratorToHashCode
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
Compares a read-only set with an object for equality. Returnstrueif 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 seto- an object- Returns:
trueif the object is equal to the set
-
asSet
Wraps this set in the Set interface - without copying.- Returns:
- the wrapped set
-
equals
Compares the specified object with this set for equality.Returns
trueif 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). -
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>). -
characteristics
default int characteristics()Returns the Spliterator characteristics of this collection.The default implementation returns
Spliterator.SIZED|Spliterator.DISTINCT.- Specified by:
characteristicsin interfaceReadOnlyCollection<E>- Returns:
- the characteristics
-