~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/ParallelIterable.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 2014 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;
 
18
 
 
19
import java.util.Comparator;
 
20
 
 
21
import com.gs.collections.api.annotation.Beta;
 
22
import com.gs.collections.api.bag.MutableBag;
 
23
import com.gs.collections.api.block.function.Function;
 
24
import com.gs.collections.api.block.function.Function0;
 
25
import com.gs.collections.api.block.function.Function2;
 
26
import com.gs.collections.api.block.function.primitive.DoubleFunction;
 
27
import com.gs.collections.api.block.function.primitive.FloatFunction;
 
28
import com.gs.collections.api.block.function.primitive.IntFunction;
 
29
import com.gs.collections.api.block.function.primitive.LongFunction;
 
30
import com.gs.collections.api.block.predicate.Predicate;
 
31
import com.gs.collections.api.block.predicate.Predicate2;
 
32
import com.gs.collections.api.block.procedure.Procedure;
 
33
import com.gs.collections.api.block.procedure.Procedure2;
 
34
import com.gs.collections.api.list.MutableList;
 
35
import com.gs.collections.api.map.MapIterable;
 
36
import com.gs.collections.api.map.MutableMap;
 
37
import com.gs.collections.api.map.sorted.MutableSortedMap;
 
38
import com.gs.collections.api.multimap.Multimap;
 
39
import com.gs.collections.api.set.MutableSet;
 
40
import com.gs.collections.api.set.sorted.MutableSortedSet;
 
41
 
 
42
/**
 
43
 * A ParallelIterable is RichIterable which will defer evaluation for certain methods like select, reject, collect, etc.
 
44
 * Any methods that do not return a ParallelIterable when called will cause evaluation to be forced. Evaluation occurs
 
45
 * in parallel. All code blocks passed in must be stateless or thread-safe.
 
46
 *
 
47
 * @since 5.0
 
48
 */
 
49
@Beta
 
50
public interface ParallelIterable<T>
 
51
{
 
52
    ParallelIterable<T> asUnique();
 
53
 
 
54
    /**
 
55
     * Creates a parallel iterable for selecting elements from the current iterable.
 
56
     */
 
57
    ParallelIterable<T> select(Predicate<? super T> predicate);
 
58
 
 
59
    <P> ParallelIterable<T> selectWith(Predicate2<? super T, ? super P> predicate, P parameter);
 
60
 
 
61
    <S> ParallelIterable<S> selectInstancesOf(Class<S> clazz);
 
62
 
 
63
    /**
 
64
     * Creates a parallel iterable for rejecting elements from the current iterable.
 
65
     */
 
66
    ParallelIterable<T> reject(Predicate<? super T> predicate);
 
67
 
 
68
    <P> ParallelIterable<T> rejectWith(Predicate2<? super T, ? super P> predicate, P parameter);
 
69
 
 
70
    /**
 
71
     * Creates a parallel iterable for collecting elements from the current iterable.
 
72
     */
 
73
    <V> ParallelIterable<V> collect(Function<? super T, ? extends V> function);
 
74
 
 
75
    <P, V> ParallelIterable<V> collectWith(Function2<? super T, ? super P, ? extends V> function, P parameter);
 
76
 
 
77
    /**
 
78
     * Creates a parallel iterable for selecting and collecting elements from the current iterable.
 
79
     */
 
80
    <V> ParallelIterable<V> collectIf(Predicate<? super T> predicate, Function<? super T, ? extends V> function);
 
81
 
 
82
    /**
 
83
     * Creates a parallel flattening iterable for the current iterable.
 
84
     */
 
85
    <V> ParallelIterable<V> flatCollect(Function<? super T, ? extends Iterable<V>> function);
 
86
 
 
87
//    /**
 
88
//     * Returns a parallel BooleanIterable which will transform the underlying iterable data to boolean values based on the booleanFunction.
 
89
//     */
 
90
//    ParallelBooleanIterable collectBoolean(BooleanFunction<? super T> booleanFunction);
 
91
//
 
92
//    /**
 
93
//     * Returns a parallel ByteIterable which will transform the underlying iterable data to byte values based on the byteFunction.
 
94
//     */
 
95
//    ParallelByteIterable collectByte(ByteFunction<? super T> byteFunction);
 
96
//
 
97
//    /**
 
98
//     * Returns a parallel CharIterable which will transform the underlying iterable data to char values based on the charFunction.
 
99
//     */
 
100
//    ParallelCharIterable collectChar(CharFunction<? super T> charFunction);
 
101
//
 
102
//    /**
 
103
//     * Returns a parallel DoubleIterable which will transform the underlying iterable data to double values based on the doubleFunction.
 
104
//     */
 
105
//    ParallelDoubleIterable collectDouble(DoubleFunction<? super T> doubleFunction);
 
106
//
 
107
//    /**
 
108
//     * Returns a parallel FloatIterable which will transform the underlying iterable data to float values based on the floatFunction.
 
109
//     */
 
110
//    ParallelFloatIterable collectFloat(FloatFunction<? super T> floatFunction);
 
111
//
 
112
//    /**
 
113
//     * Returns a parallel IntIterable which will transform the underlying iterable data to int values based on the intFunction.
 
114
//     */
 
115
//    ParallelIntIterable collectInt(IntFunction<? super T> intFunction);
 
116
//
 
117
//    /**
 
118
//     * Returns a parallel LongIterable which will transform the underlying iterable data to long values based on the longFunction.
 
119
//     */
 
120
//    ParallelLongIterable collectLong(LongFunction<? super T> longFunction);
 
121
//
 
122
//    /**
 
123
//     * Returns a parallel ShortIterable which will transform the underlying iterable data to short values based on the shortFunction.
 
124
//     */
 
125
//    ParallelShortIterable collectShort(ShortFunction<? super T> shortFunction);
 
126
 
 
127
    void forEach(Procedure<? super T> procedure);
 
128
 
 
129
    <P> void forEachWith(Procedure2<? super T, ? super P> procedure, P parameter);
 
130
 
 
131
    T detect(Predicate<? super T> predicate);
 
132
 
 
133
    <P> T detectWith(Predicate2<? super T, ? super P> predicate, P parameter);
 
134
 
 
135
    T detectIfNone(Predicate<? super T> predicate, Function0<? extends T> function);
 
136
 
 
137
    <P> T detectWithIfNone(Predicate2<? super T, ? super P> predicate, P parameter, Function0<? extends T> function);
 
138
 
 
139
    int count(Predicate<? super T> predicate);
 
140
 
 
141
    <P> int countWith(Predicate2<? super T, ? super P> predicate, P parameter);
 
142
 
 
143
    boolean anySatisfy(Predicate<? super T> predicate);
 
144
 
 
145
    <P> boolean anySatisfyWith(Predicate2<? super T, ? super P> predicate, P parameter);
 
146
 
 
147
    boolean allSatisfy(Predicate<? super T> predicate);
 
148
 
 
149
    <P> boolean allSatisfyWith(Predicate2<? super T, ? super P> predicate, P parameter);
 
150
 
 
151
    boolean noneSatisfy(Predicate<? super T> predicate);
 
152
 
 
153
    <P> boolean noneSatisfyWith(Predicate2<? super T, ? super P> predicate, P parameter);
 
154
 
 
155
    MutableList<T> toList();
 
156
 
 
157
    MutableList<T> toSortedList();
 
158
 
 
159
    MutableList<T> toSortedList(Comparator<? super T> comparator);
 
160
 
 
161
    <V extends Comparable<? super V>> MutableList<T> toSortedListBy(Function<? super T, ? extends V> function);
 
162
 
 
163
    MutableSet<T> toSet();
 
164
 
 
165
    MutableSortedSet<T> toSortedSet();
 
166
 
 
167
    MutableSortedSet<T> toSortedSet(Comparator<? super T> comparator);
 
168
 
 
169
    <V extends Comparable<? super V>> MutableSortedSet<T> toSortedSetBy(Function<? super T, ? extends V> function);
 
170
 
 
171
    MutableBag<T> toBag();
 
172
 
 
173
    <NK, NV> MutableMap<NK, NV> toMap(Function<? super T, ? extends NK> keyFunction, Function<? super T, ? extends NV> valueFunction);
 
174
 
 
175
    <NK, NV> MutableSortedMap<NK, NV> toSortedMap(Function<? super T, ? extends NK> keyFunction, Function<? super T, ? extends NV> valueFunction);
 
176
 
 
177
    <NK, NV> MutableSortedMap<NK, NV> toSortedMap(Comparator<? super NK> comparator, Function<? super T, ? extends NK> keyFunction, Function<? super T, ? extends NV> valueFunction);
 
178
 
 
179
    Object[] toArray();
 
180
 
 
181
    <T1> T1[] toArray(T1[] target);
 
182
 
 
183
    T min(Comparator<? super T> comparator);
 
184
 
 
185
    T max(Comparator<? super T> comparator);
 
186
 
 
187
    T min();
 
188
 
 
189
    T max();
 
190
 
 
191
    <V extends Comparable<? super V>> T minBy(Function<? super T, ? extends V> function);
 
192
 
 
193
    <V extends Comparable<? super V>> T maxBy(Function<? super T, ? extends V> function);
 
194
 
 
195
    long sumOfInt(IntFunction<? super T> function);
 
196
 
 
197
    double sumOfFloat(FloatFunction<? super T> function);
 
198
 
 
199
    long sumOfLong(LongFunction<? super T> function);
 
200
 
 
201
    double sumOfDouble(DoubleFunction<? super T> function);
 
202
 
 
203
    String makeString();
 
204
 
 
205
    String makeString(String separator);
 
206
 
 
207
    String makeString(String start, String separator, String end);
 
208
 
 
209
    void appendString(Appendable appendable);
 
210
 
 
211
    void appendString(Appendable appendable, String separator);
 
212
 
 
213
    void appendString(Appendable appendable, String start, String separator, String end);
 
214
 
 
215
    <V> Multimap<V, T> groupBy(Function<? super T, ? extends V> function);
 
216
 
 
217
    <V> Multimap<V, T> groupByEach(Function<? super T, ? extends Iterable<V>> function);
 
218
 
 
219
    <V> MapIterable<V, T> groupByUniqueKey(Function<? super T, ? extends V> function);
 
220
 
 
221
    <K, V> MapIterable<K, V> aggregateInPlaceBy(Function<? super T, ? extends K> groupBy, Function0<? extends V> zeroValueFactory, Procedure2<? super V, ? super T> mutatingAggregator);
 
222
 
 
223
    <K, V> MapIterable<K, V> aggregateBy(Function<? super T, ? extends K> groupBy, Function0<? extends V> zeroValueFactory, Function2<? super V, ? super T, ? extends V> nonMutatingAggregator);
 
224
}