Class AbstractBag<T>

java.lang.Object
org.eclipse.collections.impl.AbstractRichIterable<T>
org.eclipse.collections.impl.bag.AbstractBag<T>
All Implemented Interfaces:
Iterable<T>, Collection<T>, Bag<T>, InternalIterable<T>, RichIterable<T>
Direct Known Subclasses:
AbstractImmutableBagIterable, AbstractMutableBagIterable

public abstract class AbstractBag<T>
extends AbstractRichIterable<T>
implements Collection<T>, Bag<T>
Since:
7.0
  • Constructor Details

  • Method Details

    • select

      public <R extends Collection<T>> R select​(Predicate<? super T> predicate, R target)
      Description copied from interface: RichIterable
      Same as the select method with one parameter but uses the specified target collection for the results.

      Example using a Java 8 lambda expression:

       MutableList<Person> selected =
           people.select(person -> person.person.getLastName().equals("Smith"), Lists.mutable.empty());
       

      Example using an anonymous inner class:

       MutableList<Person> selected =
           people.select(new Predicate<Person>()
           {
               public boolean accept(Person person)
               {
                   return person.person.getLastName().equals("Smith");
               }
           }, Lists.mutable.empty());
       

      Specified by:
      select in interface RichIterable<T>
      Overrides:
      select in class AbstractRichIterable<T>
      Parameters:
      predicate - a Predicate to use as the select criteria
      target - the Collection to append to for all elements in this RichIterable that meet select criteria predicate
      Returns:
      target, which contains appended elements as a result of the select criteria
      See Also:
      RichIterable.select(Predicate)
    • selectWith

      public <P,​ R extends Collection<T>> R selectWith​(Predicate2<? super T,​? super P> predicate, P parameter, R target)
      Description copied from interface: RichIterable
      Similar to RichIterable.select(Predicate, Collection), except with an evaluation parameter for the second generic argument in Predicate2.

      E.g. return a Collection of Person elements where the person has an age greater than or equal to 18 years

      Example using a Java 8 lambda expression:

       MutableList<Person> selected =
           people.selectWith((Person person, Integer age) -> person.getAge()>= age, Integer.valueOf(18), Lists.mutable.empty());
       

      Example using an anonymous inner class:

       MutableList<Person> selected =
           people.selectWith(new Predicate2<Person, Integer>()
           {
               public boolean accept(Person person, Integer age)
               {
                   return person.getAge()>= age;
               }
           }, Integer.valueOf(18), Lists.mutable.empty());
       
      Specified by:
      selectWith in interface RichIterable<T>
      Overrides:
      selectWith in class AbstractRichIterable<T>
      Parameters:
      predicate - a Predicate2 to use as the select criteria
      parameter - a parameter to pass in for evaluation of the second argument P in predicate
      target - the Collection to append to for all elements in this RichIterable that meet select criteria predicate
      Returns:
      targetCollection, which contains appended elements as a result of the select criteria
      See Also:
      RichIterable.select(Predicate), RichIterable.select(Predicate, Collection)
    • reject

      public <R extends Collection<T>> R reject​(Predicate<? super T> predicate, R target)
      Description copied from interface: RichIterable
      Same as the reject method with one parameter but uses the specified target collection for the results.

      Example using a Java 8 lambda expression:

       MutableList<Person> rejected =
           people.reject(person -> person.person.getLastName().equals("Smith"), Lists.mutable.empty());
       

      Example using an anonymous inner class:

       MutableList<Person> rejected =
           people.reject(new Predicate<Person>()
           {
               public boolean accept(Person person)
               {
                   return person.person.getLastName().equals("Smith");
               }
           }, Lists.mutable.empty());
       
      Specified by:
      reject in interface RichIterable<T>
      Overrides:
      reject in class AbstractRichIterable<T>
      Parameters:
      predicate - a Predicate to use as the reject criteria
      target - the Collection to append to for all elements in this RichIterable that cause Predicate#accept(Object) method to evaluate to false
      Returns:
      target, which contains appended elements as a result of the reject criteria
    • rejectWith

      public <P,​ R extends Collection<T>> R rejectWith​(Predicate2<? super T,​? super P> predicate, P parameter, R target)
      Description copied from interface: RichIterable
      Similar to RichIterable.reject(Predicate, Collection), except with an evaluation parameter for the second generic argument in Predicate2.

      E.g. return a Collection of Person elements where the person has an age greater than or equal to 18 years

      Example using a Java 8 lambda expression:

       MutableList<Person> rejected =
           people.rejectWith((Person person, Integer age) -> person.getAge() < age, Integer.valueOf(18), Lists.mutable.empty());
       

      Example using an anonymous inner class:

       MutableList<Person> rejected =
           people.rejectWith(new Predicate2<Person, Integer>()
           {
               public boolean accept(Person person, Integer age)
               {
                   return person.getAge() < age;
               }
           }, Integer.valueOf(18), Lists.mutable.empty());
       
      Specified by:
      rejectWith in interface RichIterable<T>
      Overrides:
      rejectWith in class AbstractRichIterable<T>
      Parameters:
      predicate - a Predicate2 to use as the reject criteria
      parameter - a parameter to pass in for evaluation of the second argument P in predicate
      target - the Collection to append to for all elements in this RichIterable that cause Predicate#accept(Object) method to evaluate to false
      Returns:
      targetCollection, which contains appended elements as a result of the reject criteria
      See Also:
      RichIterable.reject(Predicate), RichIterable.reject(Predicate, Collection)
    • count

      public int count​(Predicate<? super T> predicate)
      Description copied from interface: RichIterable
      Return the total number of elements that answer true to the specified predicate.

      Example using a Java 8 lambda expression:

       int count =
           people.count(person -> person.getAddress().getState().getName().equals("New York"));
       

      Example using an anonymous inner class:

       int count =
           people.count(new Predicate<Person>()
           {
               public boolean accept(Person person)
               {
                   return person.getAddress().getState().getName().equals("New York");
               }
           });
       
      Specified by:
      count in interface RichIterable<T>
      Overrides:
      count in class AbstractRichIterable<T>
    • collect

      public <V,​ R extends Collection<V>> R collect​(Function<? super T,​? extends V> function, R target)
      Description copied from interface: RichIterable
      Same as RichIterable.collect(Function), except that the results are gathered into the specified target collection.

      Example using a Java 8 lambda expression:

       MutableList<String> names =
           people.collect(person -> person.getFirstName() + " " + person.getLastName(), Lists.mutable.empty());
       

      Example using an anonymous inner class:

       MutableList<String> names =
           people.collect(new Function<Person, String>()
           {
               public String valueOf(Person person)
               {
                   return person.getFirstName() + " " + person.getLastName();
               }
           }, Lists.mutable.empty());
       
      Specified by:
      collect in interface RichIterable<T>
      Overrides:
      collect in class AbstractRichIterable<T>
      Parameters:
      function - a Function to use as the collect transformation function
      target - the Collection to append to for all elements in this RichIterable that meet select criteria function
      Returns:
      target, which contains appended elements as a result of the collect transformation
      See Also:
      RichIterable.collect(Function)
    • collectWith

      public <P,​ V,​ R extends Collection<V>> R collectWith​(Function2<? super T,​? super P,​? extends V> function, P parameter, R target)
      Description copied from interface: RichIterable
      Same as collectWith but with a targetCollection parameter to gather the results.

      Example using a Java 8 lambda expression:

       MutableSet<Integer> integers =
           Lists.mutable.with(1, 2, 3).collectWith((each, parameter) -> each + parameter, Integer.valueOf(1), Sets.mutable.empty());
       

      Example using an anonymous inner class:

       Function2<Integer, Integer, Integer> addParameterFunction =
           new Function2<Integer, Integer, Integer>()
           {
               public Integer value(final Integer each, final Integer parameter)
               {
                   return each + parameter;
               }
           };
       MutableSet<Integer> integers =
           Lists.mutable.with(1, 2, 3).collectWith(addParameterFunction, Integer.valueOf(1), Sets.mutable.empty());
       
      Specified by:
      collectWith in interface RichIterable<T>
      Overrides:
      collectWith in class AbstractRichIterable<T>
      Parameters:
      function - a Function2 to use as the collect transformation function
      parameter - a parameter to pass in for evaluation of the second argument P in function
      target - the Collection to append to for all elements in this RichIterable that meet select criteria function
      Returns:
      targetCollection, which contains appended elements as a result of the collect transformation
    • collectIf

      public <V,​ R extends Collection<V>> R collectIf​(Predicate<? super T> predicate, Function<? super T,​? extends V> function, R target)
      Description copied from interface: RichIterable
      Same as the collectIf method with two parameters but uses the specified target collection for the results.
      Specified by:
      collectIf in interface RichIterable<T>
      Overrides:
      collectIf in class AbstractRichIterable<T>
      Parameters:
      predicate - a Predicate to use as the select criteria
      function - a Function to use as the collect transformation function
      target - the Collection to append to for all elements in this RichIterable that meet the collect criteria predicate
      Returns:
      targetCollection, which contains appended elements as a result of the collect criteria and transformation
      See Also:
      RichIterable.collectIf(Predicate, Function)
    • flatCollect

      public <V,​ R extends Collection<V>> R flatCollect​(Function<? super T,​? extends Iterable<V>> function, R target)
      Description copied from interface: RichIterable
      Same as flatCollect, only the results are collected into the target collection.
      Specified by:
      flatCollect in interface RichIterable<T>
      Overrides:
      flatCollect in class AbstractRichIterable<T>
      Parameters:
      function - The Function to apply
      target - The collection into which results should be added.
      Returns:
      target, which will contain a flattened collection of results produced by applying the given function
      See Also:
      RichIterable.flatCollect(Function)
    • collectBoolean

      public <R extends MutableBooleanCollection> R collectBoolean​(BooleanFunction<? super T> booleanFunction, R target)
      Description copied from interface: RichIterable
      Same as RichIterable.collectBoolean(BooleanFunction), except that the results are gathered into the specified target collection.

      Example using a Java 8 lambda expression:

       BooleanArrayList licenses =
           people.collectBoolean(person -> person.hasDrivingLicense(), new BooleanArrayList());
       

      Example using an anonymous inner class:

       BooleanArrayList licenses =
           people.collectBoolean(new BooleanFunction<Person>()
           {
               public boolean booleanValueOf(Person person)
               {
                   return person.hasDrivingLicense();
               }
           }, new BooleanArrayList());
       
      Specified by:
      collectBoolean in interface RichIterable<T>
      Overrides:
      collectBoolean in class AbstractRichIterable<T>
      Parameters:
      booleanFunction - a BooleanFunction to use as the collect transformation function
      target - the MutableBooleanCollection to append to for all elements in this RichIterable
      Returns:
      target, which contains appended elements as a result of the collect transformation
    • flatCollectBoolean

      public <R extends MutableBooleanCollection> R flatCollectBoolean​(Function<? super T,​? extends BooleanIterable> function, R target)
      Description copied from interface: RichIterable
      Same as flatCollect, only the results are collected into the target collection.
      Specified by:
      flatCollectBoolean in interface RichIterable<T>
      Parameters:
      function - The Function to apply
      target - The collection into which results should be added.
      Returns:
      target, which will contain a flattened collection of results produced by applying the given function
      See Also:
      RichIterable.flatCollect(Function)
    • collectByte

      public <R extends MutableByteCollection> R collectByte​(ByteFunction<? super T> byteFunction, R target)
      Description copied from interface: RichIterable
      Same as RichIterable.collectByte(ByteFunction), except that the results are gathered into the specified target collection.

      Example using a Java 8 lambda expression:

       ByteArrayList bytes =
           people.collectByte(person -> person.getCode(), new ByteArrayList());
       

      Example using an anonymous inner class:

       ByteArrayList bytes =
           people.collectByte(new ByteFunction<Person>()
           {
               public byte byteValueOf(Person person)
               {
                   return person.getCode();
               }
           }, new ByteArrayList());
       
      Specified by:
      collectByte in interface RichIterable<T>
      Overrides:
      collectByte in class AbstractRichIterable<T>
      Parameters:
      byteFunction - a ByteFunction to use as the collect transformation function
      target - the MutableByteCollection to append to for all elements in this RichIterable
      Returns:
      target, which contains appended elements as a result of the collect transformation
    • flatCollectByte

      public <R extends MutableByteCollection> R flatCollectByte​(Function<? super T,​? extends ByteIterable> function, R target)
      Description copied from interface: RichIterable
      Same as flatCollect, only the results are collected into the target collection.
      Specified by:
      flatCollectByte in interface RichIterable<T>
      Parameters:
      function - The Function to apply
      target - The collection into which results should be added.
      Returns:
      target, which will contain a flattened collection of results produced by applying the given function
      See Also:
      RichIterable.flatCollect(Function)
    • collectChar

      public <R extends MutableCharCollection> R collectChar​(CharFunction<? super T> charFunction, R target)
      Description copied from interface: RichIterable
      Same as RichIterable.collectChar(CharFunction), except that the results are gathered into the specified target collection.

      Example using a Java 8 lambda expression:

       CharArrayList chars =
           people.collectChar(person -> person.getMiddleInitial(), new CharArrayList());
       

      Example using an anonymous inner class:

       CharArrayList chars =
           people.collectChar(new CharFunction<Person>()
           {
               public char charValueOf(Person person)
               {
                   return person.getMiddleInitial();
               }
           }, new CharArrayList());
       
      Specified by:
      collectChar in interface RichIterable<T>
      Overrides:
      collectChar in class AbstractRichIterable<T>
      Parameters:
      charFunction - a CharFunction to use as the collect transformation function
      target - the MutableCharCollection to append to for all elements in this RichIterable
      Returns:
      target, which contains appended elements as a result of the collect transformation
    • flatCollectChar

      public <R extends MutableCharCollection> R flatCollectChar​(Function<? super T,​? extends CharIterable> function, R target)
      Description copied from interface: RichIterable
      Same as flatCollect, only the results are collected into the target collection.
      Specified by:
      flatCollectChar in interface RichIterable<T>
      Parameters:
      function - The Function to apply
      target - The collection into which results should be added.
      Returns:
      target, which will contain a flattened collection of results produced by applying the given function
      See Also:
      RichIterable.flatCollect(Function)
    • collectDouble

      public <R extends MutableDoubleCollection> R collectDouble​(DoubleFunction<? super T> doubleFunction, R target)
      Description copied from interface: RichIterable
      Same as RichIterable.collectDouble(DoubleFunction), except that the results are gathered into the specified target collection.

      Example using a Java 8 lambda expression:

       DoubleArrayList doubles =
           people.collectDouble(person -> person.getMilesFromNorthPole(), new DoubleArrayList());
       

      Example using an anonymous inner class:

       DoubleArrayList doubles =
           people.collectDouble(new DoubleFunction<Person>()
           {
               public double doubleValueOf(Person person)
               {
                   return person.getMilesFromNorthPole();
               }
           }, new DoubleArrayList());
       
      Specified by:
      collectDouble in interface RichIterable<T>
      Overrides:
      collectDouble in class AbstractRichIterable<T>
      Parameters:
      doubleFunction - a DoubleFunction to use as the collect transformation function
      target - the MutableDoubleCollection to append to for all elements in this RichIterable
      Returns:
      target, which contains appended elements as a result of the collect transformation
    • flatCollectDouble

      public <R extends MutableDoubleCollection> R flatCollectDouble​(Function<? super T,​? extends DoubleIterable> function, R target)
      Description copied from interface: RichIterable
      Same as flatCollect, only the results are collected into the target collection.
      Specified by:
      flatCollectDouble in interface RichIterable<T>
      Parameters:
      function - The Function to apply
      target - The collection into which results should be added.
      Returns:
      target, which will contain a flattened collection of results produced by applying the given function
      See Also:
      RichIterable.flatCollect(Function)
    • collectFloat

      public <R extends MutableFloatCollection> R collectFloat​(FloatFunction<? super T> floatFunction, R target)
      Description copied from interface: RichIterable
      Same as RichIterable.collectFloat(FloatFunction), except that the results are gathered into the specified target collection.

      Example using a Java 8 lambda expression:

       FloatArrayList floats =
           people.collectFloat(person -> person.getHeightInInches(), new FloatArrayList());
       

      Example using an anonymous inner class:

       FloatArrayList floats =
           people.collectFloat(new FloatFunction<Person>()
           {
               public float floatValueOf(Person person)
               {
                   return person.getHeightInInches();
               }
           }, new FloatArrayList());
       
      Specified by:
      collectFloat in interface RichIterable<T>
      Overrides:
      collectFloat in class AbstractRichIterable<T>
      Parameters:
      floatFunction - a FloatFunction to use as the collect transformation function
      target - the MutableFloatCollection to append to for all elements in this RichIterable
      Returns:
      target, which contains appended elements as a result of the collect transformation
    • flatCollectFloat

      public <R extends MutableFloatCollection> R flatCollectFloat​(Function<? super T,​? extends FloatIterable> function, R target)
      Description copied from interface: RichIterable
      Same as flatCollect, only the results are collected into the target collection.
      Specified by:
      flatCollectFloat in interface RichIterable<T>
      Parameters:
      function - The Function to apply
      target - The collection into which results should be added.
      Returns:
      target, which will contain a flattened collection of results produced by applying the given function
      See Also:
      RichIterable.flatCollect(Function)
    • collectInt

      public <R extends MutableIntCollection> R collectInt​(IntFunction<? super T> intFunction, R target)
      Description copied from interface: RichIterable
      Same as RichIterable.collectInt(IntFunction), except that the results are gathered into the specified target collection.

      Example using a Java 8 lambda expression:

       IntArrayList ints =
           people.collectInt(person -> person.getAge(), new IntArrayList());
       

      Example using an anonymous inner class:

       IntArrayList ints =
           people.collectInt(new IntFunction<Person>()
           {
               public int intValueOf(Person person)
               {
                   return person.getAge();
               }
           }, new IntArrayList());
       
      Specified by:
      collectInt in interface RichIterable<T>
      Overrides:
      collectInt in class AbstractRichIterable<T>
      Parameters:
      intFunction - a IntFunction to use as the collect transformation function
      target - the MutableIntCollection to append to for all elements in this RichIterable
      Returns:
      target, which contains appended elements as a result of the collect transformation
    • flatCollectInt

      public <R extends MutableIntCollection> R flatCollectInt​(Function<? super T,​? extends IntIterable> function, R target)
      Description copied from interface: RichIterable
      Same as flatCollect, only the results are collected into the target collection.
      Specified by:
      flatCollectInt in interface RichIterable<T>
      Parameters:
      function - The Function to apply
      target - The collection into which results should be added.
      Returns:
      target, which will contain a flattened collection of results produced by applying the given function
      See Also:
      RichIterable.flatCollect(Function)
    • collectLong

      public <R extends MutableLongCollection> R collectLong​(LongFunction<? super T> longFunction, R target)
      Description copied from interface: RichIterable
      Same as RichIterable.collectLong(LongFunction), except that the results are gathered into the specified target collection.

      Example using a Java 8 lambda expression:

       LongArrayList longs =
           people.collectLong(person -> person.getGuid(), new LongArrayList());
       

      Example using an anonymous inner class:

       LongArrayList longs =
           people.collectLong(new LongFunction<Person>()
           {
               public long longValueOf(Person person)
               {
                   return person.getGuid();
               }
           }, new LongArrayList());
       
      Specified by:
      collectLong in interface RichIterable<T>
      Overrides:
      collectLong in class AbstractRichIterable<T>
      Parameters:
      longFunction - a LongFunction to use as the collect transformation function
      target - the MutableLongCollection to append to for all elements in this RichIterable
      Returns:
      target, which contains appended elements as a result of the collect transformation
    • flatCollectLong

      public <R extends MutableLongCollection> R flatCollectLong​(Function<? super T,​? extends LongIterable> function, R target)
      Description copied from interface: RichIterable
      Same as flatCollect, only the results are collected into the target collection.
      Specified by:
      flatCollectLong in interface RichIterable<T>
      Parameters:
      function - The Function to apply
      target - The collection into which results should be added.
      Returns:
      target, which will contain a flattened collection of results produced by applying the given function
      See Also:
      RichIterable.flatCollect(Function)
    • collectShort

      public <R extends MutableShortCollection> R collectShort​(ShortFunction<? super T> shortFunction, R target)
      Description copied from interface: RichIterable
      Same as RichIterable.collectShort(ShortFunction), except that the results are gathered into the specified target collection.

      Example using a Java 8 lambda expression:

       ShortArrayList shorts =
           people.collectShort(person -> person.getNumberOfJunkMailItemsReceivedPerMonth, new ShortArrayList());
       

      Example using an anonymous inner class:

       ShortArrayList shorts =
           people.collectShort(new ShortFunction<Person>()
           {
               public short shortValueOf(Person person)
               {
                   return person.getNumberOfJunkMailItemsReceivedPerMonth;
               }
           }, new ShortArrayList());
       
      Specified by:
      collectShort in interface RichIterable<T>
      Overrides:
      collectShort in class AbstractRichIterable<T>
      Parameters:
      shortFunction - a ShortFunction to use as the collect transformation function
      target - the MutableShortCollection to append to for all elements in this RichIterable
      Returns:
      target, which contains appended elements as a result of the collect transformation
    • flatCollectShort

      public <R extends MutableShortCollection> R flatCollectShort​(Function<? super T,​? extends ShortIterable> function, R target)
      Description copied from interface: RichIterable
      Same as flatCollect, only the results are collected into the target collection.
      Specified by:
      flatCollectShort in interface RichIterable<T>
      Parameters:
      function - The Function to apply
      target - The collection into which results should be added.
      Returns:
      target, which will contain a flattened collection of results produced by applying the given function
      See Also:
      RichIterable.flatCollect(Function)
    • groupBy

      public <V,​ R extends MutableMultimap<V,​ T>> R groupBy​(Function<? super T,​? extends V> function, R target)
      Description copied from interface: RichIterable
      Same as RichIterable.groupBy(Function), except that the results are gathered into the specified target multimap.

      Example using a Java 8 method reference:

       FastListMultimap<String, Person> peopleByLastName =
           people.groupBy(Person::getLastName, new FastListMultimap<String, Person>());
       

      Example using an anonymous inner class:

       FastListMultimap<String, Person> peopleByLastName =
           people.groupBy(new Function<Person, String>()
           {
               public String valueOf(Person person)
               {
                   return person.getLastName();
               }
           }, new FastListMultimap<String, Person>());
       
      Specified by:
      groupBy in interface RichIterable<T>
      Overrides:
      groupBy in class AbstractRichIterable<T>
    • groupByEach

      public <V,​ R extends MutableMultimap<V,​ T>> R groupByEach​(Function<? super T,​? extends Iterable<V>> function, R target)
      Description copied from interface: RichIterable
      Same as RichIterable.groupByEach(Function), except that the results are gathered into the specified target multimap.
      Specified by:
      groupByEach in interface RichIterable<T>
      Overrides:
      groupByEach in class AbstractRichIterable<T>
    • sumOfInt

      public long sumOfInt​(IntFunction<? super T> function)
      Description copied from interface: RichIterable
      Returns the final long result of evaluating function for each element of the iterable and adding the results together.
      Specified by:
      sumOfInt in interface RichIterable<T>
      Overrides:
      sumOfInt in class AbstractRichIterable<T>
    • sumOfFloat

      public double sumOfFloat​(FloatFunction<? super T> function)
      Description copied from interface: RichIterable
      Returns the final double result of evaluating function for each element of the iterable and adding the results together. It uses Kahan summation algorithm to reduce numerical error.
      Specified by:
      sumOfFloat in interface RichIterable<T>
      Overrides:
      sumOfFloat in class AbstractRichIterable<T>
    • sumOfLong

      public long sumOfLong​(LongFunction<? super T> function)
      Description copied from interface: RichIterable
      Returns the final long result of evaluating function for each element of the iterable and adding the results together.
      Specified by:
      sumOfLong in interface RichIterable<T>
      Overrides:
      sumOfLong in class AbstractRichIterable<T>
    • sumOfDouble

      public double sumOfDouble​(DoubleFunction<? super T> function)
      Description copied from interface: RichIterable
      Returns the final double result of evaluating function for each element of the iterable and adding the results together. It uses Kahan summation algorithm to reduce numerical error.
      Specified by:
      sumOfDouble in interface RichIterable<T>
      Overrides:
      sumOfDouble in class AbstractRichIterable<T>
    • injectInto

      public <IV> IV injectInto​(IV injectedValue, Function2<? super IV,​? super T,​? extends IV> function)
      Description copied from interface: RichIterable
      Returns the final result of evaluating function using each element of the iterable and the previous evaluation result as the parameters. The injected value is used for the first parameter of the first evaluation, and the current item in the iterable is used as the second parameter. This method is commonly called fold or sometimes reduce.
      Specified by:
      injectInto in interface RichIterable<T>
      Overrides:
      injectInto in class AbstractRichIterable<T>
    • injectInto

      public int injectInto​(int injectedValue, IntObjectToIntFunction<? super T> function)
      Description copied from interface: RichIterable
      Returns the final int result of evaluating function using each element of the iterable and the previous evaluation result as the parameters. The injected value is used for the first parameter of the first evaluation, and the current item in the iterable is used as the second parameter.
      Specified by:
      injectInto in interface RichIterable<T>
      Overrides:
      injectInto in class AbstractRichIterable<T>
    • injectInto

      public long injectInto​(long injectedValue, LongObjectToLongFunction<? super T> function)
      Description copied from interface: RichIterable
      Returns the final long result of evaluating function using each element of the iterable and the previous evaluation result as the parameters. The injected value is used for the first parameter of the first evaluation, and the current item in the iterable is used as the second parameter.
      Specified by:
      injectInto in interface RichIterable<T>
      Overrides:
      injectInto in class AbstractRichIterable<T>
    • injectInto

      public double injectInto​(double injectedValue, DoubleObjectToDoubleFunction<? super T> function)
      Description copied from interface: RichIterable
      Returns the final double result of evaluating function using each element of the iterable and the previous evaluation result as the parameters. The injected value is used for the first parameter of the first evaluation, and the current item in the iterable is used as the second parameter.
      Specified by:
      injectInto in interface RichIterable<T>
      Overrides:
      injectInto in class AbstractRichIterable<T>
    • injectInto

      public float injectInto​(float injectedValue, FloatObjectToFloatFunction<? super T> function)
      Description copied from interface: RichIterable
      Returns the final float result of evaluating function using each element of the iterable and the previous evaluation result as the parameters. The injected value is used for the first parameter of the first evaluation, and the current item in the iterable is used as the second parameter.
      Specified by:
      injectInto in interface RichIterable<T>
      Overrides:
      injectInto in class AbstractRichIterable<T>
    • injectIntoWith

      public <IV,​ P> IV injectIntoWith​(IV injectedValue, Function3<? super IV,​? super T,​? super P,​? extends IV> function, P parameter)
    • toStringOfItemToCount

      public String toStringOfItemToCount()
      Description copied from interface: Bag
      Returns a string representation of this bag. The string representation consists of a list of element-count mappings.
       Assert.assertEquals("{1=1, 2=2, 3=3}", Bags.mutable.with(1, 2, 2, 3, 3, 3).toStringOfItemToCount());
       
      This string representation is similar to AbstractMap.toString(), not RichIterable.toString(), whereas the toString() implementation for a Bag is consistent with RichIterable.toString().
      Specified by:
      toStringOfItemToCount in interface Bag<T>
      Returns:
      a string representation of this bag
    • toList

      public MutableList<T> toList()
      Description copied from interface: RichIterable
      Converts the collection to a MutableList implementation.
      Specified by:
      toList in interface RichIterable<T>
      Overrides:
      toList in class AbstractRichIterable<T>
    • toSortedList

      public MutableList<T> toSortedList​(Comparator<? super T> comparator)
      Description copied from interface: RichIterable
      Converts the collection to a MutableList implementation and sorts it using the specified comparator.
      Specified by:
      toSortedList in interface RichIterable<T>
    • toSet

      public MutableSet<T> toSet()
      Description copied from interface: RichIterable
      Converts the collection to a MutableSet implementation.
      Specified by:
      toSet in interface RichIterable<T>
      Overrides:
      toSet in class AbstractRichIterable<T>
    • toSortedSet

      public MutableSortedSet<T> toSortedSet()
      Description copied from interface: RichIterable
      Converts the collection to a MutableSortedSet implementation and sorts it using the natural order of the elements.
      Specified by:
      toSortedSet in interface RichIterable<T>
      Overrides:
      toSortedSet in class AbstractRichIterable<T>
    • toSortedSet

      public MutableSortedSet<T> toSortedSet​(Comparator<? super T> comparator)
      Description copied from interface: RichIterable
      Converts the collection to a MutableSortedSet implementation and sorts it using the specified comparator.
      Specified by:
      toSortedSet in interface RichIterable<T>
      Overrides:
      toSortedSet in class AbstractRichIterable<T>
    • toBag

      public MutableBag<T> toBag()
      Description copied from interface: RichIterable
      Converts the collection to the default MutableBag implementation.
      Specified by:
      toBag in interface RichIterable<T>
      Overrides:
      toBag in class AbstractRichIterable<T>
    • toSortedBag

      public MutableSortedBag<T> toSortedBag()
      Description copied from interface: RichIterable
      Converts the collection to a MutableSortedBag implementation and sorts it using the natural order of the elements.
      Specified by:
      toSortedBag in interface RichIterable<T>
      Overrides:
      toSortedBag in class AbstractRichIterable<T>
    • toSortedBag

      public MutableSortedBag<T> toSortedBag​(Comparator<? super T> comparator)
      Description copied from interface: RichIterable
      Converts the collection to the MutableSortedBag implementation and sorts it using the specified comparator.
      Specified by:
      toSortedBag in interface RichIterable<T>
      Overrides:
      toSortedBag in class AbstractRichIterable<T>