Interface EconomicSet<E>
- All Superinterfaces:
Iterable<E>, UnmodifiableEconomicSet<E>
Memory efficient set data structure. It does not support adding, looking up or removing a
null element.- Since:
- 19.0
-
Method Summary
Modifier and TypeMethodDescriptionbooleanAdds non-nullelementto this set if it is not already present.default voidAdds all the elements invaluesto this set if they're not already present.default voidAdds all the elements enumerated byiteratorto this set if they're not already present.default voidaddAll(EconomicSet<? extends E> other) Adds all the elements inotherto this set if they're not already present.voidclear()Removes all the elements from this set.static <E> EconomicSet<E> create()Creates a new set guaranteeing insertion order when iterating over its elements with the defaultEquivalence.DEFAULTcomparison strategy.static <E> EconomicSet<E> create(int initialCapacity) Creates a new set guaranteeing insertion order when iterating over its elements with the defaultEquivalence.DEFAULTcomparison strategy.static <E> EconomicSet<E> Creates a new set guaranteeing insertion order when iterating over its elements with the defaultEquivalence.DEFAULTcomparison strategy and inserts all elements of the specified iterable.static <E> EconomicSet<E> create(Equivalence strategy) Creates a new set guaranteeing insertion order when iterating over its elements.static <E> EconomicSet<E> create(Equivalence strategy, int initialCapacity) Creates a new set guaranteeing insertion order when iterating over its elements and initializes with the given capacity.static <E> EconomicSet<E> create(Equivalence strategy, UnmodifiableEconomicSet<E> c) Creates a new set guaranteeing insertion order when iterating over its elements and inserts all elements of the specified collection.static <E> EconomicSet<E> Creates a new set guaranteeing insertion order when iterating over its elements with the defaultEquivalence.DEFAULTcomparison strategy and inserts all elements of the specified collection.static <E> EconomicSet<E> emptySet()Return an empty, unmodifiableEconomicSet.static <E> EconomicSet<E> of(E elem) voidRemoves non-nullelementfrom this set if it is present.default voidRemoves from this set all of its elements that are contained invalues.default voidRemoves from this set all of its elements that are enumerated byiterator.default voidremoveAll(EconomicSet<E> other) Removes from this set all of its elements that are contained inother.default voidretainAll(EconomicSet<E> other) Removes from this set all of its elements that are not contained inother.Methods inherited from interface Iterable
forEach, iterator, spliteratorMethods inherited from interface UnmodifiableEconomicSet
contains, containsAll, isEmpty, removeIf, size, toArray, toHashSet, toList
-
Method Details
-
add
Adds non-nullelementto this set if it is not already present.- Returns:
trueif this set did not already containelement- Throws:
UnsupportedOperationException- ifelement == null- Since:
- 19.0
-
remove
Removes non-nullelementfrom this set if it is present. This set will not containelementonce the call returns.- Throws:
UnsupportedOperationException- ifelement == null- Since:
- 19.0
-
clear
void clear()Removes all the elements from this set. The set will be empty after this call returns.- Since:
- 19.0
-
addAll
Adds all the elements inotherto this set if they're not already present.- Since:
- 19.0
-
addAll
-
addAll
-
removeAll
Removes from this set all of its elements that are contained inother.- Since:
- 19.0
-
removeAll
-
removeAll
-
retainAll
Removes from this set all of its elements that are not contained inother.- Since:
- 19.0
-
create
Creates a new set guaranteeing insertion order when iterating over its elements with the defaultEquivalence.DEFAULTcomparison strategy.- Since:
- 19.0
-
create
Creates a new set guaranteeing insertion order when iterating over its elements.- Since:
- 19.0
-
create
Creates a new set guaranteeing insertion order when iterating over its elements with the defaultEquivalence.DEFAULTcomparison strategy.- Since:
- 19.0
-
create
Creates a new set guaranteeing insertion order when iterating over its elements with the defaultEquivalence.DEFAULTcomparison strategy and inserts all elements of the specified collection.- Since:
- 19.0
-
create
Creates a new set guaranteeing insertion order when iterating over its elements and initializes with the given capacity.- Since:
- 19.0
-
create
Creates a new set guaranteeing insertion order when iterating over its elements and inserts all elements of the specified collection.- Since:
- 19.0
-
create
Creates a new set guaranteeing insertion order when iterating over its elements with the defaultEquivalence.DEFAULTcomparison strategy and inserts all elements of the specified iterable.- Since:
- 25.1
-
emptySet
-
of
-