Module org.jhotdraw8.icollection
Package org.jhotdraw8.icollection.facade
Class ImmutableSetFacade<E>
java.lang.Object
org.jhotdraw8.icollection.readonly.AbstractReadOnlyCollection<E>
org.jhotdraw8.icollection.readonly.AbstractReadOnlySet<E>
org.jhotdraw8.icollection.facade.ImmutableSetFacade<E>
- Type Parameters:
E- the element type
- All Implemented Interfaces:
Iterable<E>,ImmutableCollection<E>,ImmutableSet<E>,ReadOnlyCollection<E>,ReadOnlySet<E>
Provides a
ImmutableSet facade to a set of ImmutableSet functions.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns a copy of this set that contains all elements of this set and also the specified element.Returns a copy of this set that contains all elements of this set and also all elements of the specified collection.intReturns the Spliterator characteristics of this collection.booleanReturnstrueif this collection contains the specified object.<T> ImmutableSet<T> empty()Returns an empty set instance that has the specified element type.iterator()Returns an iterator over the elements in this collection.intmaxSize()Returns the maximal number of elements that this collection type can holdReturns a copy of this set that contains all elements of this set except the specified element.Returns a copy of this set that contains all elements of this set except the elements of the specified collection.Returns a copy of this set that contains only elements that are in this set and in the specified collection.intsize()Returns the size of the collection.Returns a mutable copy of this set.Methods inherited from class org.jhotdraw8.icollection.readonly.AbstractReadOnlySet
equals, hashCodeMethods inherited from class org.jhotdraw8.icollection.readonly.AbstractReadOnlyCollection
toStringMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.jhotdraw8.icollection.immutable.ImmutableCollection
filterMethods inherited from interface org.jhotdraw8.icollection.readonly.ReadOnlyCollection
asCollection, containsAll, isEmpty, stream, toArray, toArrayMethods inherited from interface org.jhotdraw8.icollection.readonly.ReadOnlySet
asSet, equals, hashCode
-
Constructor Details
-
ImmutableSetFacade
-
-
Method Details
-
empty
Description copied from interface:ImmutableSetReturns an empty set instance that has the specified element type.- Specified by:
emptyin interfaceImmutableCollection<E>- Specified by:
emptyin interfaceImmutableSet<E>- Type Parameters:
T- the element type of the returned set- Returns:
- an empty set of the specified element type.
-
add
Description copied from interface:ImmutableSetReturns a copy of this set that contains all elements of this set and also the specified element.- Specified by:
addin interfaceImmutableCollection<E>- Specified by:
addin interfaceImmutableSet<E>- Parameters:
element- an element- Returns:
- this set instance if it already contains the element, or a different set instance with the element added
-
addAll
Description copied from interface:ImmutableSetReturns a copy of this set that contains all elements of this set and also all elements of the specified collection.- Specified by:
addAllin interfaceImmutableCollection<E>- Specified by:
addAllin interfaceImmutableSet<E>- Parameters:
c- a collection to be added to this set- Returns:
- this set instance if it already contains the elements, or a different set instance with the elements added
-
remove
Description copied from interface:ImmutableSetReturns a copy of this set that contains all elements of this set except the specified element.- Specified by:
removein interfaceImmutableCollection<E>- Specified by:
removein interfaceImmutableSet<E>- Parameters:
element- an element- Returns:
- this set instance if it already does not contain the element, or a different set instance with the element removed
-
removeAll
Description copied from interface:ImmutableSetReturns a copy of this set that contains all elements of this set except the elements of the specified collection.- Specified by:
removeAllin interfaceImmutableCollection<E>- Specified by:
removeAllin interfaceImmutableSet<E>- Parameters:
c- a collection with elements to be removed from this set- Returns:
- this set instance if it already does not contain the elements, or a different set instance with the elements removed
-
retainAll
Description copied from interface:ImmutableSetReturns a copy of this set that contains only elements that are in this set and in the specified collection.- Specified by:
retainAllin interfaceImmutableCollection<E>- Specified by:
retainAllin interfaceImmutableSet<E>- Parameters:
c- a collection with elements to be retained in this set- Returns:
- this set instance if it has not changed, or a different set instance with elements removed
-
size
public int size()Description copied from interface:ReadOnlyCollectionReturns the size of the collection.- Specified by:
sizein interfaceReadOnlyCollection<E>- Returns:
- the size
-
contains
Description copied from interface:ReadOnlyCollectionReturnstrueif this collection contains the specified object.- Specified by:
containsin interfaceReadOnlyCollection<E>- Overrides:
containsin classAbstractReadOnlyCollection<E>- Parameters:
o- an object- Returns:
trueif this collection contains the specified object
-
maxSize
public int maxSize()Description copied from interface:ImmutableCollectionReturns the maximal number of elements that this collection type can hold- Specified by:
maxSizein interfaceImmutableCollection<E>- Returns:
- the maximal size
-
iterator
Description copied from interface:ReadOnlyCollectionReturns an iterator over the elements in this collection. -
spliterator
- Specified by:
spliteratorin interfaceIterable<E>
-
toMutable
Description copied from interface:ImmutableSetReturns a mutable copy of this set.- Specified by:
toMutablein interfaceImmutableCollection<E>- Specified by:
toMutablein interfaceImmutableSet<E>- Returns:
- a mutable copy.
-
characteristics
public int characteristics()Description copied from interface:ReadOnlySetReturns the Spliterator characteristics of this collection.The default implementation returns
Spliterator.SIZED|Spliterator.DISTINCT.- Specified by:
characteristicsin interfaceReadOnlyCollection<E>- Specified by:
characteristicsin interfaceReadOnlySet<E>- Returns:
- the characteristics
-