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

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

Go to download

GS Collections is a collections framework for Java. It has JDK-compatible List, Set and Map implementations with a rich API and set of utility classes that work with any JDK compatible Collections, Arrays, Maps or Strings. The iteration protocol was inspired by the Smalltalk collection framework.

There is a newer version: 7.0.3
Show newest version
/*
 * 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 elements);

    MutableList withoutAll(Iterable elements);

    MutableList newEmpty();

    MutableList clone();

    MutableList select(Predicate predicate);

    

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

MutableList rejectWith(Predicate2 predicate, P parameter); PartitionMutableList partition(Predicate predicate); 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); MutableList distinct(); /** * 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); 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 takeWhile(Predicate predicate); 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(); }