Class AbstractMutableCollection<T>

    • Constructor Detail

      • AbstractMutableCollection

        public AbstractMutableCollection()
    • Method Detail

      • selectAndRejectWith

        public <P> Twin<MutableList<T>> selectAndRejectWith​(Predicate2<? super T,​? super P> predicate,
                                                            P parameter)
        Description copied from interface: MutableCollection
        Filters a collection into two separate collections based on a predicate returned via a Pair.
        e.g.
         return lastNames.selectAndRejectWith(Predicates2.lessThan(), "Mason");
         
        Specified by:
        selectAndRejectWith in interface MutableCollection<T>
      • removeIf

        public boolean removeIf​(Predicate<? super T> predicate)
        Description copied from interface: MutableCollection
        Removes all elements in the collection that evaluate to true for the specified predicate.
        e.g.
         return lastNames.removeIf(Predicates.isNull());
         
        Specified by:
        removeIf in interface MutableCollection<T>
      • removeIfWith

        public <P> boolean removeIfWith​(Predicate2<? super T,​? super P> predicate,
                                        P parameter)
        Description copied from interface: MutableCollection
        Removes all elements in the collection that evaluate to true for the specified predicate2 and parameter.
         return lastNames.removeIfWith(Predicates2.isNull(), null);
         
        Specified by:
        removeIfWith in interface MutableCollection<T>
      • injectIntoWith

        public <IV,​P> IV injectIntoWith​(IV injectValue,
                                              Function3<? super IV,​? super T,​? super P,​? extends IV> function,
                                              P parameter)
        Description copied from interface: MutableCollection
        Returns the final result of evaluating function using each element of the iterable, the previous evaluation result and 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. The parameter value is always used as the third parameter to the function call.
        Specified by:
        injectIntoWith in interface MutableCollection<T>
        See Also:
        RichIterable.injectInto(Object, Function2)
      • reduce

        public java.util.Optional<T> reduce​(java.util.function.BinaryOperator<T> accumulator)
        Description copied from interface: RichIterable
        This method produces the equivalent result as Stream.reduce(BinaryOperator).
        Specified by:
        reduce in interface RichIterable<T>
      • addAllIterable

        public boolean addAllIterable​(java.lang.Iterable<? extends T> iterable)
        Specified by:
        addAllIterable in interface MutableCollection<T>
        See Also:
        Collection.addAll(Collection)
      • removeAllIterable

        public boolean removeAllIterable​(java.lang.Iterable<?> iterable)
        Specified by:
        removeAllIterable in interface MutableCollection<T>
        See Also:
        Collection.removeAll(Collection)
      • retainAllIterable

        public boolean retainAllIterable​(java.lang.Iterable<?> iterable)
        Specified by:
        retainAllIterable in interface MutableCollection<T>
        See Also:
        Collection.retainAll(Collection)
      • chunk

        public RichIterable<RichIterable<T>> chunk​(int size)
        Description copied from interface: RichIterable
        Partitions elements in fixed size chunks.
        Specified by:
        chunk in interface RichIterable<T>
        Parameters:
        size - the number of elements per chunk
        Returns:
        A RichIterable containing RichIterables of size size, except the last will be truncated if the elements don't divide evenly.
      • add

        public boolean add​(T element)
        Specified by:
        add in interface java.util.Collection<T>
      • remove

        public boolean remove​(java.lang.Object o)
        Specified by:
        remove in interface java.util.Collection<T>
      • addAll

        public boolean addAll​(java.util.Collection<? extends T> source)
        Specified by:
        addAll in interface java.util.Collection<T>
      • removeAll

        public boolean removeAll​(java.util.Collection<?> source)
        Specified by:
        removeAll in interface java.util.Collection<T>
      • retainAll

        public boolean retainAll​(java.util.Collection<?> source)
        Specified by:
        retainAll in interface java.util.Collection<T>
      • countBy

        public <V> MutableBag<V> countBy​(Function<? super T,​? extends V> function)
        Description copied from interface: RichIterable
        This method will count the number of occurrences of each value calculated by applying the function to each element of the collection.
        Specified by:
        countBy in interface MutableCollection<T>
        Specified by:
        countBy in interface RichIterable<T>
        Since:
        9.0
      • countByWith

        public <V,​P> MutableBag<V> countByWith​(Function2<? super T,​? super P,​? extends V> function,
                                                     P parameter)
        Description copied from interface: RichIterable
        This method will count the number of occurrences of each value calculated by applying the function to each element of the collection with the specified parameter as the second argument.
        Specified by:
        countByWith in interface MutableCollection<T>
        Specified by:
        countByWith in interface RichIterable<T>
        Since:
        9.0