- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Represents a function that adds an element to a set if not already present.
The set can be implemented in various ways. For example:
- The set can be an implementation of one of the collection classes
provided by the Java API.
AddToIntSet=new HashSet<Integer>()::add; - The set can be a marker bit in a
BitSet.AddToIntSet=AddToIntSet.addToBitSet(new BitSet());
- Author:
- Werner Randelshofer
-
Method Summary
Modifier and TypeMethodDescriptiondefault booleanAdds the specified element to the set if it is not already present.booleanaddAsInt(int e) Adds the specified element to the set if it is not already present.static @NonNull AddToIntSetaddToBitSet(@NonNull BitSet bitSet) Creates an instance that adds to a bit set.
-
Method Details
-
add
Description copied from interface:AddToSetAdds the specified element to the set if it is not already present. -
addAsInt
boolean addAsInt(int e) Adds the specified element to the set if it is not already present.- Parameters:
e- element to be added to the set- Returns:
trueif this set did not already contain the specified element
-
addToBitSet
Creates an instance that adds to a bit set.- Parameters:
bitSet- a bit set- Returns:
- a new instance
-