com.gs.collections.api.list.MutableList Maven / Gradle / Ivy
Show all versions of gs-collections-api Show documentation
/*
* Copyright 2013 Goldman Sachs.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.gs.collections.api.list;
import java.util.Comparator;
import java.util.List;
import com.gs.collections.api.block.function.Function;
import com.gs.collections.api.block.function.Function2;
import com.gs.collections.api.block.function.primitive.BooleanFunction;
import com.gs.collections.api.block.function.primitive.ByteFunction;
import com.gs.collections.api.block.function.primitive.CharFunction;
import com.gs.collections.api.block.function.primitive.DoubleFunction;
import com.gs.collections.api.block.function.primitive.FloatFunction;
import com.gs.collections.api.block.function.primitive.IntFunction;
import com.gs.collections.api.block.function.primitive.LongFunction;
import com.gs.collections.api.block.function.primitive.ShortFunction;
import com.gs.collections.api.block.predicate.Predicate;
import com.gs.collections.api.block.predicate.Predicate2;
import com.gs.collections.api.collection.MutableCollection;
import com.gs.collections.api.list.primitive.MutableBooleanList;
import com.gs.collections.api.list.primitive.MutableByteList;
import com.gs.collections.api.list.primitive.MutableCharList;
import com.gs.collections.api.list.primitive.MutableDoubleList;
import com.gs.collections.api.list.primitive.MutableFloatList;
import com.gs.collections.api.list.primitive.MutableIntList;
import com.gs.collections.api.list.primitive.MutableLongList;
import com.gs.collections.api.list.primitive.MutableShortList;
import com.gs.collections.api.multimap.list.MutableListMultimap;
import com.gs.collections.api.partition.list.PartitionMutableList;
import com.gs.collections.api.tuple.Pair;
/**
* A MutableList is an implementation of a JCF List which provides methods matching the Smalltalk Collection protocol.
*/
public interface MutableList
extends MutableCollection, List, Cloneable, ListIterable
{
MutableList with(T element);
MutableList without(T element);
MutableList withAll(Iterable extends T> elements);
MutableList withoutAll(Iterable extends T> elements);
MutableList newEmpty();
MutableList clone();
MutableList select(Predicate super T> predicate);
MutableList selectWith(Predicate2 super T, ? super P> predicate, P parameter);
MutableList reject(Predicate super T> predicate);
MutableList rejectWith(Predicate2 super T, ? super P> predicate, P parameter);
PartitionMutableList partition(Predicate super T> predicate);
MutableList selectInstancesOf(Class clazz);
MutableList collect(Function super T, ? extends V> function);
MutableBooleanList collectBoolean(BooleanFunction super T> booleanFunction);
MutableByteList collectByte(ByteFunction super T> byteFunction);
MutableCharList collectChar(CharFunction super T> charFunction);
MutableDoubleList collectDouble(DoubleFunction super T> doubleFunction);
MutableFloatList collectFloat(FloatFunction super T> floatFunction);
MutableIntList collectInt(IntFunction super T> intFunction);
MutableLongList collectLong(LongFunction super T> longFunction);
MutableShortList collectShort(ShortFunction super T> shortFunction);
MutableList collectWith(Function2 super T, ? super P, ? extends V> function, P parameter);
MutableList collectIf(Predicate super T> predicate, Function super T, ? extends V> function);
MutableList flatCollect(Function super T, ? extends Iterable> function);
MutableList distinct();
/**
* Sorts the internal data structure of this list and returns the list itself as a convenience.
*/
MutableList sortThis(Comparator super T> comparator);
/**
* Sorts the internal data structure of this list and returns the list itself as a convenience.
*/
MutableList sortThis();
/**
* Sorts the internal data structure of this list based on the natural order of the attribute returned by {@code
* function}.
*/
> MutableList sortThisBy(Function super T, ? extends V> function);
MutableList subList(int fromIndex, int toIndex);
/**
* Returns an unmodifable view of the list.
* The returned list will be Serializable if this list is Serializable.
*
* @return an unmodifiable view of this list
*/
MutableList asUnmodifiable();
MutableList asSynchronized();
/**
* Returns an immutable copy of this list. If the list is immutable, it returns itself.
* The returned list will be Serializable if this list is Serializable.
*/
ImmutableList toImmutable();
MutableListMultimap groupBy(Function super T, ? extends V> function);
MutableListMultimap groupByEach(Function super T, ? extends Iterable> function);
MutableList> zip(Iterable that);
MutableList> zipWithIndex();
MutableList takeWhile(Predicate super T> predicate);
MutableList dropWhile(Predicate super T> predicate);
PartitionMutableList partitionWhile(Predicate super T> predicate);
/**
* Returns a new MutableList in reverse order
*/
MutableList toReversed();
/**
* Mutates the current list by reversing its order and returns the current list as a result
*/
MutableList reverseThis();
}