Interface AddToIntSet

All Superinterfaces:
AddToSet<Integer>
Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface AddToIntSet extends AddToSet<Integer>
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 Type
    Method
    Description
    default boolean
    add(Integer integer)
    Adds the specified element to the set if it is not already present.
    boolean
    addAsInt(int e)
    Adds the specified element to the set if it is not already present.
    Creates an instance that adds to a bit set.
  • Method Details

    • add

      default boolean add(Integer integer)
      Description copied from interface: AddToSet
      Adds the specified element to the set if it is not already present.
      Specified by:
      add in interface AddToSet<Integer>
      Parameters:
      integer - element to be added to the set
      Returns:
      true if this set did not already contain the specified element
    • 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:
      true if this set did not already contain the specified element
    • addToBitSet

      static @NonNull AddToIntSet addToBitSet(@NonNull BitSet bitSet)
      Creates an instance that adds to a bit set.
      Parameters:
      bitSet - a bit set
      Returns:
      a new instance