java.lang.Object
org.jhotdraw8.icollection.ChampAddOnlySet<E>
- Type Parameters:
E- the element type
- All Implemented Interfaces:
ImmutableAddOnlySet<E>
Implements the
ImmutableAddOnlySet interface using a Compressed
Hash-Array Mapped Prefix-tree (CHAMP).
Performance characteristics:
- add: O(log₃₂ N)
References:
- Michael J. Steindorfer (2017). Efficient Immutable Collections.
- michael.steindorfer.name
- The Capsule Hash Trie Collections Library.
Copyright (c) Michael Steindorfer. BSD-2-Clause License - github.com
-
Method Summary
Modifier and TypeMethodDescriptionReturns a copy of this set that contains all elements of this set and also the specified element.static <E> @NonNull ChampAddOnlySet<E> of()Returns an empty set.static <E> @NonNull ChampAddOnlySet<E> Returns a set that contains the specified elements.
-
Method Details
-
of
Returns an empty set.- Type Parameters:
E- the element type.- Returns:
- an empty set.
-
of
Returns a set that contains the specified elements.- Type Parameters:
E- the element type.- Parameters:
elements- the specified elements- Returns:
- a set of the specified elements.
-
add
Description copied from interface:ImmutableAddOnlySetReturns a copy of this set that contains all elements of this set and also the specified element.- Specified by:
addin interfaceImmutableAddOnlySet<E>- Parameters:
key- an element- Returns:
- this set if it already contains the element, or a different set with the element added
-