All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.gs.collections.api.list.MutableList Maven / Gradle / Ivy

/*
 * Copyright 2015 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 java.util.Random;

import com.gs.collections.api.RichIterable;
import com.gs.collections.api.block.HashingStrategy;
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.block.procedure.Procedure;
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 elements);

    MutableList withoutAll(Iterable elements);

    MutableList newEmpty();

    MutableList clone();

    MutableList tap(Procedure procedure);

    MutableList select(Predicate predicate);

    

MutableList selectWith(Predicate2 predicate, P parameter); MutableList reject(Predicate predicate);

MutableList rejectWith(Predicate2 predicate, P parameter); PartitionMutableList partition(Predicate predicate);

PartitionMutableList partitionWith(Predicate2 predicate, P parameter); MutableList selectInstancesOf(Class clazz); MutableList collect(Function function); MutableBooleanList collectBoolean(BooleanFunction booleanFunction); MutableByteList collectByte(ByteFunction byteFunction); MutableCharList collectChar(CharFunction charFunction); MutableDoubleList collectDouble(DoubleFunction doubleFunction); MutableFloatList collectFloat(FloatFunction floatFunction); MutableIntList collectInt(IntFunction intFunction); MutableLongList collectLong(LongFunction longFunction); MutableShortList collectShort(ShortFunction shortFunction); MutableList collectWith(Function2 function, P parameter); MutableList collectIf(Predicate predicate, Function function); MutableList flatCollect(Function> function); /** * Returns a new {@code ListIterable} containing the distinct elements in this list. * * @since 7.0 */ MutableList distinct(); /** * Returns a new {@code ListIterable} containing the distinct elements in this list. Takes HashingStrategy. * * @since 7.0 */ MutableList distinct(HashingStrategy hashingStrategy); /** * Sorts the internal data structure of this list and returns the list itself as a convenience. */ MutableList sortThis(Comparator 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 function); /** * @since 6.0 */ MutableList sortThisByInt(IntFunction function); /** * @since 6.0 */ MutableList sortThisByBoolean(BooleanFunction function); /** * @since 6.0 */ MutableList sortThisByChar(CharFunction function); /** * @since 6.0 */ MutableList sortThisByByte(ByteFunction function); /** * @since 6.0 */ MutableList sortThisByShort(ShortFunction function); /** * @since 6.0 */ MutableList sortThisByFloat(FloatFunction function); /** * @since 6.0 */ MutableList sortThisByLong(LongFunction function); /** * @since 6.0 */ MutableList sortThisByDouble(DoubleFunction 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 function); MutableListMultimap groupByEach(Function> function); MutableList> zip(Iterable that); MutableList> zipWithIndex(); MutableList take(int count); MutableList takeWhile(Predicate predicate); MutableList drop(int count); MutableList dropWhile(Predicate predicate); PartitionMutableList partitionWhile(Predicate 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(); MutableList shuffleThis(); MutableList shuffleThis(Random rnd); }