Interface FixedSizeSet<T>

All Superinterfaces:
Cloneable, Collection<T>, FixedSizeCollection<T>, InternalIterable<T>, Iterable<T>, MutableCollection<T>, MutableSet<T>, MutableSetIterable<T>, RichIterable<T>, Set<T>, SetIterable<T>, UnsortedSetIterable<T>

public interface FixedSizeSet<T>
extends MutableSet<T>, FixedSizeCollection<T>
A FixedSizeSet is a set that may be mutated, but cannot grow or shrink in size.
  • Method Details

    • with

      MutableSet<T> with​(T element)
      Description copied from interface: MutableCollection
      This method allows mutable and fixed size collections the ability to add elements to their existing elements. In order to support fixed size a new instance of a collection would have to be returned taking the elements of the original collection and appending the new element to form the new collection. In the case of mutable collections, the original collection is modified, and is returned. In order to use this method properly with mutable and fixed size collections the following approach must be taken:
       MutableCollection<String> list = list.with("1");
       list = list.with("2");
       return list;
       
      In the case of FixedSizeCollection a new instance of MutableCollection will be returned by with, and any variables that previously referenced the original collection will need to be redirected to reference the new instance. For other MutableCollection types you will replace the reference to collection with the same collection, since the instance will return "this" after calling add on itself.
      Specified by:
      with in interface FixedSizeCollection<T>
      Specified by:
      with in interface MutableCollection<T>
      Specified by:
      with in interface MutableSet<T>
      Specified by:
      with in interface MutableSetIterable<T>
      See Also:
      Collection.add(Object)
    • without

      MutableSet<T> without​(T element)
      Description copied from interface: MutableCollection
      This method allows mutable and fixed size collections the ability to remove elements from their existing elements. In order to support fixed size a new instance of a collection would have to be returned containing the elements that would be left from the original collection after calling remove. In the case of mutable collections, the original collection is modified, and is returned. In order to use this method properly with mutable and fixed size collections the following approach must be taken:
       MutableCollection<String> list = list.without("1");
       list = list.without("2");
       return list;
       
      In the case of FixedSizeCollection a new instance of MutableCollection will be returned by without, and any variables that previously referenced the original collection will need to be redirected to reference the new instance. For other MutableCollection types you will replace the reference to collection with the same collection, since the instance will return "this" after calling remove on itself.
      Specified by:
      without in interface FixedSizeCollection<T>
      Specified by:
      without in interface MutableCollection<T>
      Specified by:
      without in interface MutableSet<T>
      Specified by:
      without in interface MutableSetIterable<T>
      See Also:
      Collection.remove(Object)
    • withAll

      MutableSet<T> withAll​(Iterable<? extends T> elements)
      Description copied from interface: MutableCollection
      This method allows mutable and fixed size collections the ability to add multiple elements to their existing elements. In order to support fixed size a new instance of a collection would have to be returned taking the elements of the original collection and appending the new elements to form the new collection. In the case of mutable collections, the original collection is modified, and is returned. In order to use this method properly with mutable and fixed size collections the following approach must be taken:
       MutableCollection<String> list = list.withAll(FastList.newListWith("1", "2"));
       
      In the case of FixedSizeCollection a new instance of MutableCollection will be returned by withAll, and any variables that previously referenced the original collection will need to be redirected to reference the new instance. For other MutableCollection types you will replace the reference to collection with the same collection, since the instance will return "this" after calling addAll on itself.
      Specified by:
      withAll in interface FixedSizeCollection<T>
      Specified by:
      withAll in interface MutableCollection<T>
      Specified by:
      withAll in interface MutableSet<T>
      Specified by:
      withAll in interface MutableSetIterable<T>
      See Also:
      Collection.addAll(Collection)
    • withoutAll

      MutableSet<T> withoutAll​(Iterable<? extends T> elements)
      Description copied from interface: MutableCollection
      This method allows mutable and fixed size collections the ability to remove multiple elements from their existing elements. In order to support fixed size a new instance of a collection would have to be returned containing the elements that would be left from the original collection after calling removeAll. In the case of mutable collections, the original collection is modified, and is returned. In order to use this method properly with mutable and fixed size collections the following approach must be taken:
       MutableCollection<String> list = list.withoutAll(FastList.newListWith("1", "2"));
       
      In the case of FixedSizeCollection a new instance of MutableCollection will be returned by withoutAll, and any variables that previously referenced the original collection will need to be redirected to reference the new instance. For other MutableCollection types you will replace the reference to collection with the same collection, since the instance will return "this" after calling removeAll on itself.
      Specified by:
      withoutAll in interface FixedSizeCollection<T>
      Specified by:
      withoutAll in interface MutableCollection<T>
      Specified by:
      withoutAll in interface MutableSet<T>
      Specified by:
      withoutAll in interface MutableSetIterable<T>
      See Also:
      Collection.removeAll(Collection)
    • tap

      FixedSizeSet<T> tap​(Procedure<? super T> procedure)
      Description copied from interface: RichIterable
      Executes the Procedure for each element in the iterable and returns this.

      Example using a Java 8 lambda expression:

       RichIterable<Person> tapped =
           people.tap(person -> LOGGER.info(person.getName()));
       

      Example using an anonymous inner class:

       RichIterable<Person> tapped =
           people.tap(new Procedure<Person>()
           {
               public void value(Person person)
               {
                   LOGGER.info(person.getName());
               }
           });
       
      Specified by:
      tap in interface FixedSizeCollection<T>
      Specified by:
      tap in interface MutableCollection<T>
      Specified by:
      tap in interface MutableSet<T>
      Specified by:
      tap in interface MutableSetIterable<T>
      Specified by:
      tap in interface RichIterable<T>
      Specified by:
      tap in interface SetIterable<T>
      Specified by:
      tap in interface UnsortedSetIterable<T>
      See Also:
      RichIterable.each(Procedure), RichIterable.forEach(Procedure)