~ubuntu-branches/ubuntu/wily/gs-collections/wily

« back to all changes in this revision

Viewing changes to collections-api/src/main/java/com/gs/collections/api/list/MutableList.java

  • Committer: Package Import Robot
  • Author(s): Emmanuel Bourg
  • Date: 2015-07-23 12:42:30 UTC
  • Revision ID: package-import@ubuntu.com-20150723124230-2rjvfv6elyn2m7d4
Tags: upstream-5.1.0
ImportĀ upstreamĀ versionĀ 5.1.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright 2013 Goldman Sachs.
 
3
 *
 
4
 * Licensed under the Apache License, Version 2.0 (the "License");
 
5
 * you may not use this file except in compliance with the License.
 
6
 * You may obtain a copy of the License at
 
7
 *
 
8
 *     http://www.apache.org/licenses/LICENSE-2.0
 
9
 *
 
10
 * Unless required by applicable law or agreed to in writing, software
 
11
 * distributed under the License is distributed on an "AS IS" BASIS,
 
12
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
13
 * See the License for the specific language governing permissions and
 
14
 * limitations under the License.
 
15
 */
 
16
 
 
17
package com.gs.collections.api.list;
 
18
 
 
19
import java.util.Comparator;
 
20
import java.util.List;
 
21
 
 
22
import com.gs.collections.api.block.function.Function;
 
23
import com.gs.collections.api.block.function.Function2;
 
24
import com.gs.collections.api.block.function.primitive.BooleanFunction;
 
25
import com.gs.collections.api.block.function.primitive.ByteFunction;
 
26
import com.gs.collections.api.block.function.primitive.CharFunction;
 
27
import com.gs.collections.api.block.function.primitive.DoubleFunction;
 
28
import com.gs.collections.api.block.function.primitive.FloatFunction;
 
29
import com.gs.collections.api.block.function.primitive.IntFunction;
 
30
import com.gs.collections.api.block.function.primitive.LongFunction;
 
31
import com.gs.collections.api.block.function.primitive.ShortFunction;
 
32
import com.gs.collections.api.block.predicate.Predicate;
 
33
import com.gs.collections.api.block.predicate.Predicate2;
 
34
import com.gs.collections.api.collection.MutableCollection;
 
35
import com.gs.collections.api.list.primitive.MutableBooleanList;
 
36
import com.gs.collections.api.list.primitive.MutableByteList;
 
37
import com.gs.collections.api.list.primitive.MutableCharList;
 
38
import com.gs.collections.api.list.primitive.MutableDoubleList;
 
39
import com.gs.collections.api.list.primitive.MutableFloatList;
 
40
import com.gs.collections.api.list.primitive.MutableIntList;
 
41
import com.gs.collections.api.list.primitive.MutableLongList;
 
42
import com.gs.collections.api.list.primitive.MutableShortList;
 
43
import com.gs.collections.api.multimap.list.MutableListMultimap;
 
44
import com.gs.collections.api.partition.list.PartitionMutableList;
 
45
import com.gs.collections.api.tuple.Pair;
 
46
 
 
47
/**
 
48
 * A MutableList is an implementation of a JCF List which provides methods matching the Smalltalk Collection protocol.
 
49
 */
 
50
public interface MutableList<T>
 
51
        extends MutableCollection<T>, List<T>, Cloneable, ListIterable<T>
 
52
{
 
53
    MutableList<T> with(T element);
 
54
 
 
55
    MutableList<T> without(T element);
 
56
 
 
57
    MutableList<T> withAll(Iterable<? extends T> elements);
 
58
 
 
59
    MutableList<T> withoutAll(Iterable<? extends T> elements);
 
60
 
 
61
    MutableList<T> newEmpty();
 
62
 
 
63
    MutableList<T> clone();
 
64
 
 
65
    MutableList<T> select(Predicate<? super T> predicate);
 
66
 
 
67
    <P> MutableList<T> selectWith(Predicate2<? super T, ? super P> predicate, P parameter);
 
68
 
 
69
    MutableList<T> reject(Predicate<? super T> predicate);
 
70
 
 
71
    <P> MutableList<T> rejectWith(Predicate2<? super T, ? super P> predicate, P parameter);
 
72
 
 
73
    PartitionMutableList<T> partition(Predicate<? super T> predicate);
 
74
 
 
75
    <P> PartitionMutableList<T> partitionWith(Predicate2<? super T, ? super P> predicate, P parameter);
 
76
 
 
77
    <S> MutableList<S> selectInstancesOf(Class<S> clazz);
 
78
 
 
79
    <V> MutableList<V> collect(Function<? super T, ? extends V> function);
 
80
 
 
81
    MutableBooleanList collectBoolean(BooleanFunction<? super T> booleanFunction);
 
82
 
 
83
    MutableByteList collectByte(ByteFunction<? super T> byteFunction);
 
84
 
 
85
    MutableCharList collectChar(CharFunction<? super T> charFunction);
 
86
 
 
87
    MutableDoubleList collectDouble(DoubleFunction<? super T> doubleFunction);
 
88
 
 
89
    MutableFloatList collectFloat(FloatFunction<? super T> floatFunction);
 
90
 
 
91
    MutableIntList collectInt(IntFunction<? super T> intFunction);
 
92
 
 
93
    MutableLongList collectLong(LongFunction<? super T> longFunction);
 
94
 
 
95
    MutableShortList collectShort(ShortFunction<? super T> shortFunction);
 
96
 
 
97
    <P, V> MutableList<V> collectWith(Function2<? super T, ? super P, ? extends V> function, P parameter);
 
98
 
 
99
    <V> MutableList<V> collectIf(Predicate<? super T> predicate, Function<? super T, ? extends V> function);
 
100
 
 
101
    <V> MutableList<V> flatCollect(Function<? super T, ? extends Iterable<V>> function);
 
102
 
 
103
    MutableList<T> distinct();
 
104
 
 
105
    /**
 
106
     * Sorts the internal data structure of this list and returns the list itself as a convenience.
 
107
     */
 
108
    MutableList<T> sortThis(Comparator<? super T> comparator);
 
109
 
 
110
    /**
 
111
     * Sorts the internal data structure of this list and returns the list itself as a convenience.
 
112
     */
 
113
    MutableList<T> sortThis();
 
114
 
 
115
    /**
 
116
     * Sorts the internal data structure of this list based on the natural order of the attribute returned by {@code
 
117
     * function}.
 
118
     */
 
119
    <V extends Comparable<? super V>> MutableList<T> sortThisBy(Function<? super T, ? extends V> function);
 
120
 
 
121
    MutableList<T> subList(int fromIndex, int toIndex);
 
122
 
 
123
    /**
 
124
     * Returns an unmodifable view of the list.
 
125
     * The returned list will be <tt>Serializable</tt> if this list is <tt>Serializable</tt>.
 
126
     *
 
127
     * @return an unmodifiable view of this list
 
128
     */
 
129
    MutableList<T> asUnmodifiable();
 
130
 
 
131
    MutableList<T> asSynchronized();
 
132
 
 
133
    /**
 
134
     * Returns an immutable copy of this list. If the list is immutable, it returns itself.
 
135
     * The returned list will be <tt>Serializable</tt> if this list is <tt>Serializable</tt>.
 
136
     */
 
137
    ImmutableList<T> toImmutable();
 
138
 
 
139
    <V> MutableListMultimap<V, T> groupBy(Function<? super T, ? extends V> function);
 
140
 
 
141
    <V> MutableListMultimap<V, T> groupByEach(Function<? super T, ? extends Iterable<V>> function);
 
142
 
 
143
    <S> MutableList<Pair<T, S>> zip(Iterable<S> that);
 
144
 
 
145
    MutableList<Pair<T, Integer>> zipWithIndex();
 
146
 
 
147
    MutableList<T> takeWhile(Predicate<? super T> predicate);
 
148
 
 
149
    MutableList<T> dropWhile(Predicate<? super T> predicate);
 
150
 
 
151
    PartitionMutableList<T> partitionWhile(Predicate<? super T> predicate);
 
152
 
 
153
    /**
 
154
     * Returns a new MutableList in reverse order
 
155
     */
 
156
    MutableList<T> toReversed();
 
157
 
 
158
    /**
 
159
     * Mutates the current list by reversing its order and returns the current list as a result
 
160
     */
 
161
    MutableList<T> reverseThis();
 
162
}