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

« back to all changes in this revision

Viewing changes to collections/src/main/java/com/gs/collections/impl/collection/mutable/AbstractUnmodifiableMutableCollection.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.impl.collection.mutable;
 
18
 
 
19
import java.util.Collection;
 
20
import java.util.Comparator;
 
21
import java.util.Iterator;
 
22
 
 
23
import com.gs.collections.api.LazyIterable;
 
24
import com.gs.collections.api.RichIterable;
 
25
import com.gs.collections.api.bag.MutableBag;
 
26
import com.gs.collections.api.block.function.Function;
 
27
import com.gs.collections.api.block.function.Function0;
 
28
import com.gs.collections.api.block.function.Function2;
 
29
import com.gs.collections.api.block.function.Function3;
 
30
import com.gs.collections.api.block.function.primitive.BooleanFunction;
 
31
import com.gs.collections.api.block.function.primitive.ByteFunction;
 
32
import com.gs.collections.api.block.function.primitive.CharFunction;
 
33
import com.gs.collections.api.block.function.primitive.DoubleFunction;
 
34
import com.gs.collections.api.block.function.primitive.DoubleObjectToDoubleFunction;
 
35
import com.gs.collections.api.block.function.primitive.FloatFunction;
 
36
import com.gs.collections.api.block.function.primitive.FloatObjectToFloatFunction;
 
37
import com.gs.collections.api.block.function.primitive.IntFunction;
 
38
import com.gs.collections.api.block.function.primitive.IntObjectToIntFunction;
 
39
import com.gs.collections.api.block.function.primitive.LongFunction;
 
40
import com.gs.collections.api.block.function.primitive.LongObjectToLongFunction;
 
41
import com.gs.collections.api.block.function.primitive.ShortFunction;
 
42
import com.gs.collections.api.block.predicate.Predicate;
 
43
import com.gs.collections.api.block.predicate.Predicate2;
 
44
import com.gs.collections.api.block.procedure.Procedure;
 
45
import com.gs.collections.api.block.procedure.Procedure2;
 
46
import com.gs.collections.api.block.procedure.primitive.ObjectIntProcedure;
 
47
import com.gs.collections.api.collection.ImmutableCollection;
 
48
import com.gs.collections.api.collection.MutableCollection;
 
49
import com.gs.collections.api.collection.primitive.MutableBooleanCollection;
 
50
import com.gs.collections.api.collection.primitive.MutableByteCollection;
 
51
import com.gs.collections.api.collection.primitive.MutableCharCollection;
 
52
import com.gs.collections.api.collection.primitive.MutableDoubleCollection;
 
53
import com.gs.collections.api.collection.primitive.MutableFloatCollection;
 
54
import com.gs.collections.api.collection.primitive.MutableIntCollection;
 
55
import com.gs.collections.api.collection.primitive.MutableLongCollection;
 
56
import com.gs.collections.api.collection.primitive.MutableShortCollection;
 
57
import com.gs.collections.api.list.MutableList;
 
58
import com.gs.collections.api.map.MutableMap;
 
59
import com.gs.collections.api.map.sorted.MutableSortedMap;
 
60
import com.gs.collections.api.multimap.MutableMultimap;
 
61
import com.gs.collections.api.partition.PartitionMutableCollection;
 
62
import com.gs.collections.api.set.MutableSet;
 
63
import com.gs.collections.api.set.sorted.MutableSortedSet;
 
64
import com.gs.collections.api.tuple.Pair;
 
65
import com.gs.collections.api.tuple.Twin;
 
66
import com.gs.collections.impl.UnmodifiableIteratorAdapter;
 
67
import com.gs.collections.impl.block.factory.Comparators;
 
68
import com.gs.collections.impl.block.procedure.MutatingAggregationProcedure;
 
69
import com.gs.collections.impl.block.procedure.NonMutatingAggregationProcedure;
 
70
import com.gs.collections.impl.map.mutable.UnifiedMap;
 
71
import com.gs.collections.impl.utility.LazyIterate;
 
72
 
 
73
public class AbstractUnmodifiableMutableCollection<T> implements MutableCollection<T>
 
74
{
 
75
    private final MutableCollection<? extends T> collection;
 
76
 
 
77
    protected AbstractUnmodifiableMutableCollection(MutableCollection<? extends T> mutableCollection)
 
78
    {
 
79
        if (mutableCollection == null)
 
80
        {
 
81
            throw new NullPointerException("cannot create a UnmodifiableMutableCollection for null");
 
82
        }
 
83
        this.collection = mutableCollection;
 
84
    }
 
85
 
 
86
    public int size()
 
87
    {
 
88
        return this.collection.size();
 
89
    }
 
90
 
 
91
    public boolean isEmpty()
 
92
    {
 
93
        return this.collection.isEmpty();
 
94
    }
 
95
 
 
96
    public boolean contains(Object o)
 
97
    {
 
98
        return this.collection.contains(o);
 
99
    }
 
100
 
 
101
    public Iterator<T> iterator()
 
102
    {
 
103
        return new UnmodifiableIteratorAdapter<T>(this.collection.iterator());
 
104
    }
 
105
 
 
106
    public Object[] toArray()
 
107
    {
 
108
        return this.collection.toArray();
 
109
    }
 
110
 
 
111
    public <S> S[] toArray(S[] a)
 
112
    {
 
113
        return this.collection.toArray(a);
 
114
    }
 
115
 
 
116
    public boolean add(T o)
 
117
    {
 
118
        throw new UnsupportedOperationException("Cannot call add() on " + this.getClass().getSimpleName());
 
119
    }
 
120
 
 
121
    public boolean remove(Object o)
 
122
    {
 
123
        throw new UnsupportedOperationException("Cannot call remove() on " + this.getClass().getSimpleName());
 
124
    }
 
125
 
 
126
    public boolean containsAll(Collection<?> c)
 
127
    {
 
128
        return this.collection.containsAll(c);
 
129
    }
 
130
 
 
131
    public boolean addAll(Collection<? extends T> c)
 
132
    {
 
133
        throw new UnsupportedOperationException("Cannot call addAll() on " + this.getClass().getSimpleName());
 
134
    }
 
135
 
 
136
    public boolean retainAll(Collection<?> c)
 
137
    {
 
138
        throw new UnsupportedOperationException("Cannot call retainAll() on " + this.getClass().getSimpleName());
 
139
    }
 
140
 
 
141
    public boolean removeAll(Collection<?> c)
 
142
    {
 
143
        throw new UnsupportedOperationException("Cannot call removeAll() on " + this.getClass().getSimpleName());
 
144
    }
 
145
 
 
146
    public void clear()
 
147
    {
 
148
        throw new UnsupportedOperationException("Cannot call clear() on " + this.getClass().getSimpleName());
 
149
    }
 
150
 
 
151
    protected MutableCollection<T> getMutableCollection()
 
152
    {
 
153
        return (MutableCollection<T>) this.collection;
 
154
    }
 
155
 
 
156
    public boolean addAllIterable(Iterable<? extends T> iterable)
 
157
    {
 
158
        throw new UnsupportedOperationException("Cannot call addAllIterable() on " + this.getClass().getSimpleName());
 
159
    }
 
160
 
 
161
    public boolean removeAllIterable(Iterable<?> iterable)
 
162
    {
 
163
        throw new UnsupportedOperationException("Cannot call removeAllIterable() on " + this.getClass().getSimpleName());
 
164
    }
 
165
 
 
166
    public boolean retainAllIterable(Iterable<?> iterable)
 
167
    {
 
168
        throw new UnsupportedOperationException("Cannot call retainAllIterable() on " + this.getClass().getSimpleName());
 
169
    }
 
170
 
 
171
    public MutableCollection<T> asUnmodifiable()
 
172
    {
 
173
        return this;
 
174
    }
 
175
 
 
176
    public MutableCollection<T> asSynchronized()
 
177
    {
 
178
        return SynchronizedMutableCollection.of(this);
 
179
    }
 
180
 
 
181
    public ImmutableCollection<T> toImmutable()
 
182
    {
 
183
        return this.getMutableCollection().toImmutable();
 
184
    }
 
185
 
 
186
    public LazyIterable<T> asLazy()
 
187
    {
 
188
        return LazyIterate.adapt(this);
 
189
    }
 
190
 
 
191
    public void forEach(Procedure<? super T> procedure)
 
192
    {
 
193
        this.getMutableCollection().forEach(procedure);
 
194
    }
 
195
 
 
196
    public void forEachWithIndex(ObjectIntProcedure<? super T> objectIntProcedure)
 
197
    {
 
198
        this.getMutableCollection().forEachWithIndex(objectIntProcedure);
 
199
    }
 
200
 
 
201
    public <P> void forEachWith(Procedure2<? super T, ? super P> procedure, P parameter)
 
202
    {
 
203
        this.getMutableCollection().forEachWith(procedure, parameter);
 
204
    }
 
205
 
 
206
    public boolean containsAllIterable(Iterable<?> source)
 
207
    {
 
208
        return this.getMutableCollection().containsAllIterable(source);
 
209
    }
 
210
 
 
211
    public boolean containsAllArguments(Object... elements)
 
212
    {
 
213
        return this.getMutableCollection().containsAllArguments(elements);
 
214
    }
 
215
 
 
216
    public boolean notEmpty()
 
217
    {
 
218
        return this.getMutableCollection().notEmpty();
 
219
    }
 
220
 
 
221
    public MutableCollection<T> newEmpty()
 
222
    {
 
223
        return this.getMutableCollection().newEmpty();
 
224
    }
 
225
 
 
226
    public T getFirst()
 
227
    {
 
228
        return this.getMutableCollection().getFirst();
 
229
    }
 
230
 
 
231
    public T getLast()
 
232
    {
 
233
        return this.getMutableCollection().getLast();
 
234
    }
 
235
 
 
236
    public MutableCollection<T> select(Predicate<? super T> predicate)
 
237
    {
 
238
        return this.getMutableCollection().select(predicate);
 
239
    }
 
240
 
 
241
    public <R extends Collection<T>> R select(Predicate<? super T> predicate, R target)
 
242
    {
 
243
        return this.getMutableCollection().select(predicate, target);
 
244
    }
 
245
 
 
246
    public <P> MutableCollection<T> selectWith(Predicate2<? super T, ? super P> predicate, P parameter)
 
247
    {
 
248
        return this.getMutableCollection().selectWith(predicate, parameter);
 
249
    }
 
250
 
 
251
    public <P, R extends Collection<T>> R selectWith(
 
252
            Predicate2<? super T, ? super P> predicate,
 
253
            P parameter,
 
254
            R targetCollection)
 
255
    {
 
256
        return this.getMutableCollection().selectWith(predicate, parameter, targetCollection);
 
257
    }
 
258
 
 
259
    public MutableCollection<T> reject(Predicate<? super T> predicate)
 
260
    {
 
261
        return this.getMutableCollection().reject(predicate);
 
262
    }
 
263
 
 
264
    public <R extends Collection<T>> R reject(Predicate<? super T> predicate, R target)
 
265
    {
 
266
        return this.getMutableCollection().reject(predicate, target);
 
267
    }
 
268
 
 
269
    public <P> MutableCollection<T> rejectWith(Predicate2<? super T, ? super P> predicate, P parameter)
 
270
    {
 
271
        return this.getMutableCollection().rejectWith(predicate, parameter);
 
272
    }
 
273
 
 
274
    public <P, R extends Collection<T>> R rejectWith(
 
275
            Predicate2<? super T, ? super P> predicate,
 
276
            P parameter,
 
277
            R targetCollection)
 
278
    {
 
279
        return this.getMutableCollection().rejectWith(predicate, parameter, targetCollection);
 
280
    }
 
281
 
 
282
    public <P> Twin<MutableList<T>> selectAndRejectWith(
 
283
            Predicate2<? super T, ? super P> predicate,
 
284
            P parameter)
 
285
    {
 
286
        return this.getMutableCollection().selectAndRejectWith(predicate, parameter);
 
287
    }
 
288
 
 
289
    public PartitionMutableCollection<T> partition(Predicate<? super T> predicate)
 
290
    {
 
291
        return this.getMutableCollection().partition(predicate);
 
292
    }
 
293
 
 
294
    public <P> PartitionMutableCollection<T> partitionWith(Predicate2<? super T, ? super P> predicate, P parameter)
 
295
    {
 
296
        return this.getMutableCollection().partitionWith(predicate, parameter);
 
297
    }
 
298
 
 
299
    public <S> MutableCollection<S> selectInstancesOf(Class<S> clazz)
 
300
    {
 
301
        return this.getMutableCollection().selectInstancesOf(clazz);
 
302
    }
 
303
 
 
304
    public void removeIf(Predicate<? super T> predicate)
 
305
    {
 
306
        throw new UnsupportedOperationException("Cannot call removeIf() on " + this.getClass().getSimpleName());
 
307
    }
 
308
 
 
309
    public <P> void removeIfWith(Predicate2<? super T, ? super P> predicate, P parameter)
 
310
    {
 
311
        throw new UnsupportedOperationException("Cannot call removeIfWith() on " + this.getClass().getSimpleName());
 
312
    }
 
313
 
 
314
    public <V> MutableCollection<V> collect(Function<? super T, ? extends V> function)
 
315
    {
 
316
        return this.getMutableCollection().collect(function);
 
317
    }
 
318
 
 
319
    public MutableBooleanCollection collectBoolean(BooleanFunction<? super T> booleanFunction)
 
320
    {
 
321
        return this.getMutableCollection().collectBoolean(booleanFunction);
 
322
    }
 
323
 
 
324
    public <R extends MutableBooleanCollection> R collectBoolean(BooleanFunction<? super T> booleanFunction, R target)
 
325
    {
 
326
        return this.getMutableCollection().collectBoolean(booleanFunction, target);
 
327
    }
 
328
 
 
329
    public MutableByteCollection collectByte(ByteFunction<? super T> byteFunction)
 
330
    {
 
331
        return this.getMutableCollection().collectByte(byteFunction);
 
332
    }
 
333
 
 
334
    public <R extends MutableByteCollection> R collectByte(ByteFunction<? super T> byteFunction, R target)
 
335
    {
 
336
        return this.getMutableCollection().collectByte(byteFunction, target);
 
337
    }
 
338
 
 
339
    public MutableCharCollection collectChar(CharFunction<? super T> charFunction)
 
340
    {
 
341
        return this.getMutableCollection().collectChar(charFunction);
 
342
    }
 
343
 
 
344
    public <R extends MutableCharCollection> R collectChar(CharFunction<? super T> charFunction, R target)
 
345
    {
 
346
        return this.getMutableCollection().collectChar(charFunction, target);
 
347
    }
 
348
 
 
349
    public MutableDoubleCollection collectDouble(DoubleFunction<? super T> doubleFunction)
 
350
    {
 
351
        return this.getMutableCollection().collectDouble(doubleFunction);
 
352
    }
 
353
 
 
354
    public <R extends MutableDoubleCollection> R collectDouble(DoubleFunction<? super T> doubleFunction, R target)
 
355
    {
 
356
        return this.getMutableCollection().collectDouble(doubleFunction, target);
 
357
    }
 
358
 
 
359
    public MutableFloatCollection collectFloat(FloatFunction<? super T> floatFunction)
 
360
    {
 
361
        return this.getMutableCollection().collectFloat(floatFunction);
 
362
    }
 
363
 
 
364
    public <R extends MutableFloatCollection> R collectFloat(FloatFunction<? super T> floatFunction, R target)
 
365
    {
 
366
        return this.getMutableCollection().collectFloat(floatFunction, target);
 
367
    }
 
368
 
 
369
    public MutableIntCollection collectInt(IntFunction<? super T> intFunction)
 
370
    {
 
371
        return this.getMutableCollection().collectInt(intFunction);
 
372
    }
 
373
 
 
374
    public <R extends MutableIntCollection> R collectInt(IntFunction<? super T> intFunction, R target)
 
375
    {
 
376
        return this.getMutableCollection().collectInt(intFunction, target);
 
377
    }
 
378
 
 
379
    public MutableLongCollection collectLong(LongFunction<? super T> longFunction)
 
380
    {
 
381
        return this.getMutableCollection().collectLong(longFunction);
 
382
    }
 
383
 
 
384
    public <R extends MutableLongCollection> R collectLong(LongFunction<? super T> longFunction, R target)
 
385
    {
 
386
        return this.getMutableCollection().collectLong(longFunction, target);
 
387
    }
 
388
 
 
389
    public MutableShortCollection collectShort(ShortFunction<? super T> shortFunction)
 
390
    {
 
391
        return this.getMutableCollection().collectShort(shortFunction);
 
392
    }
 
393
 
 
394
    public <R extends MutableShortCollection> R collectShort(ShortFunction<? super T> shortFunction, R target)
 
395
    {
 
396
        return this.getMutableCollection().collectShort(shortFunction, target);
 
397
    }
 
398
 
 
399
    public <V, R extends Collection<V>> R collect(Function<? super T, ? extends V> function, R target)
 
400
    {
 
401
        return this.getMutableCollection().collect(function, target);
 
402
    }
 
403
 
 
404
    public <V> MutableCollection<V> flatCollect(Function<? super T, ? extends Iterable<V>> function)
 
405
    {
 
406
        return this.getMutableCollection().flatCollect(function);
 
407
    }
 
408
 
 
409
    public <V, R extends Collection<V>> R flatCollect(Function<? super T, ? extends Iterable<V>> function, R target)
 
410
    {
 
411
        return this.getMutableCollection().flatCollect(function, target);
 
412
    }
 
413
 
 
414
    public <P, A> MutableCollection<A> collectWith(Function2<? super T, ? super P, ? extends A> function, P parameter)
 
415
    {
 
416
        return this.getMutableCollection().collectWith(function, parameter);
 
417
    }
 
418
 
 
419
    public <P, A, R extends Collection<A>> R collectWith(
 
420
            Function2<? super T, ? super P, ? extends A> function,
 
421
            P parameter,
 
422
            R targetCollection)
 
423
    {
 
424
        return this.getMutableCollection().collectWith(function, parameter, targetCollection);
 
425
    }
 
426
 
 
427
    public <V> MutableCollection<V> collectIf(
 
428
            Predicate<? super T> predicate,
 
429
            Function<? super T, ? extends V> function)
 
430
    {
 
431
        return this.getMutableCollection().collectIf(predicate, function);
 
432
    }
 
433
 
 
434
    public <V, R extends Collection<V>> R collectIf(
 
435
            Predicate<? super T> predicate,
 
436
            Function<? super T, ? extends V> function,
 
437
            R target)
 
438
    {
 
439
        return this.getMutableCollection().collectIf(predicate, function, target);
 
440
    }
 
441
 
 
442
    public T detect(Predicate<? super T> predicate)
 
443
    {
 
444
        return this.getMutableCollection().detect(predicate);
 
445
    }
 
446
 
 
447
    public T min(Comparator<? super T> comparator)
 
448
    {
 
449
        return this.getMutableCollection().min(comparator);
 
450
    }
 
451
 
 
452
    public T max(Comparator<? super T> comparator)
 
453
    {
 
454
        return this.getMutableCollection().max(comparator);
 
455
    }
 
456
 
 
457
    public T min()
 
458
    {
 
459
        return this.getMutableCollection().min();
 
460
    }
 
461
 
 
462
    public T max()
 
463
    {
 
464
        return this.getMutableCollection().max();
 
465
    }
 
466
 
 
467
    public <V extends Comparable<? super V>> T minBy(Function<? super T, ? extends V> function)
 
468
    {
 
469
        return this.getMutableCollection().minBy(function);
 
470
    }
 
471
 
 
472
    public <V extends Comparable<? super V>> T maxBy(Function<? super T, ? extends V> function)
 
473
    {
 
474
        return this.getMutableCollection().maxBy(function);
 
475
    }
 
476
 
 
477
    public T detectIfNone(Predicate<? super T> predicate, Function0<? extends T> function)
 
478
    {
 
479
        return this.getMutableCollection().detectIfNone(predicate, function);
 
480
    }
 
481
 
 
482
    public <P> T detectWith(Predicate2<? super T, ? super P> predicate, P parameter)
 
483
    {
 
484
        return this.getMutableCollection().detectWith(predicate, parameter);
 
485
    }
 
486
 
 
487
    public <P> T detectWithIfNone(
 
488
            Predicate2<? super T, ? super P> predicate,
 
489
            P parameter,
 
490
            Function0<? extends T> function)
 
491
    {
 
492
        return this.getMutableCollection().detectWithIfNone(predicate, parameter, function);
 
493
    }
 
494
 
 
495
    public int count(Predicate<? super T> predicate)
 
496
    {
 
497
        return this.getMutableCollection().count(predicate);
 
498
    }
 
499
 
 
500
    public <P> int countWith(Predicate2<? super T, ? super P> predicate, P parameter)
 
501
    {
 
502
        return this.getMutableCollection().countWith(predicate, parameter);
 
503
    }
 
504
 
 
505
    public boolean anySatisfy(Predicate<? super T> predicate)
 
506
    {
 
507
        return this.getMutableCollection().anySatisfy(predicate);
 
508
    }
 
509
 
 
510
    public <P> boolean anySatisfyWith(Predicate2<? super T, ? super P> predicate, P parameter)
 
511
    {
 
512
        return this.getMutableCollection().anySatisfyWith(predicate, parameter);
 
513
    }
 
514
 
 
515
    public boolean allSatisfy(Predicate<? super T> predicate)
 
516
    {
 
517
        return this.getMutableCollection().allSatisfy(predicate);
 
518
    }
 
519
 
 
520
    public <P> boolean allSatisfyWith(Predicate2<? super T, ? super P> predicate, P parameter)
 
521
    {
 
522
        return this.getMutableCollection().allSatisfyWith(predicate, parameter);
 
523
    }
 
524
 
 
525
    public boolean noneSatisfy(Predicate<? super T> predicate)
 
526
    {
 
527
        return this.getMutableCollection().noneSatisfy(predicate);
 
528
    }
 
529
 
 
530
    public <P> boolean noneSatisfyWith(Predicate2<? super T, ? super P> predicate, P parameter)
 
531
    {
 
532
        return this.getMutableCollection().noneSatisfyWith(predicate, parameter);
 
533
    }
 
534
 
 
535
    public <IV> IV injectInto(IV injectedValue, Function2<? super IV, ? super T, ? extends IV> function)
 
536
    {
 
537
        return this.getMutableCollection().injectInto(injectedValue, function);
 
538
    }
 
539
 
 
540
    public int injectInto(int injectedValue, IntObjectToIntFunction<? super T> function)
 
541
    {
 
542
        return this.getMutableCollection().injectInto(injectedValue, function);
 
543
    }
 
544
 
 
545
    public long injectInto(long injectedValue, LongObjectToLongFunction<? super T> function)
 
546
    {
 
547
        return this.getMutableCollection().injectInto(injectedValue, function);
 
548
    }
 
549
 
 
550
    public double injectInto(double injectedValue, DoubleObjectToDoubleFunction<? super T> function)
 
551
    {
 
552
        return this.getMutableCollection().injectInto(injectedValue, function);
 
553
    }
 
554
 
 
555
    public float injectInto(float injectedValue, FloatObjectToFloatFunction<? super T> function)
 
556
    {
 
557
        return this.getMutableCollection().injectInto(injectedValue, function);
 
558
    }
 
559
 
 
560
    public long sumOfInt(IntFunction<? super T> function)
 
561
    {
 
562
        return this.getMutableCollection().sumOfInt(function);
 
563
    }
 
564
 
 
565
    public double sumOfFloat(FloatFunction<? super T> function)
 
566
    {
 
567
        return this.getMutableCollection().sumOfFloat(function);
 
568
    }
 
569
 
 
570
    public long sumOfLong(LongFunction<? super T> function)
 
571
    {
 
572
        return this.getMutableCollection().sumOfLong(function);
 
573
    }
 
574
 
 
575
    public double sumOfDouble(DoubleFunction<? super T> function)
 
576
    {
 
577
        return this.getMutableCollection().sumOfDouble(function);
 
578
    }
 
579
 
 
580
    public <IV, P> IV injectIntoWith(
 
581
            IV injectValue,
 
582
            Function3<? super IV, ? super T, ? super P, ? extends IV> function,
 
583
            P parameter)
 
584
    {
 
585
        return this.getMutableCollection().injectIntoWith(injectValue, function, parameter);
 
586
    }
 
587
 
 
588
    public MutableList<T> toList()
 
589
    {
 
590
        return this.getMutableCollection().toList();
 
591
    }
 
592
 
 
593
    public MutableList<T> toSortedList()
 
594
    {
 
595
        return this.getMutableCollection().toSortedList();
 
596
    }
 
597
 
 
598
    public MutableList<T> toSortedList(Comparator<? super T> comparator)
 
599
    {
 
600
        return this.getMutableCollection().toSortedList(comparator);
 
601
    }
 
602
 
 
603
    public <V extends Comparable<? super V>> MutableList<T> toSortedListBy(Function<? super T, ? extends V> function)
 
604
    {
 
605
        return this.getMutableCollection().toSortedList(Comparators.byFunction(function));
 
606
    }
 
607
 
 
608
    public MutableSortedSet<T> toSortedSet()
 
609
    {
 
610
        return this.getMutableCollection().toSortedSet();
 
611
    }
 
612
 
 
613
    public MutableSortedSet<T> toSortedSet(Comparator<? super T> comparator)
 
614
    {
 
615
        return this.getMutableCollection().toSortedSet(comparator);
 
616
    }
 
617
 
 
618
    public <V extends Comparable<? super V>> MutableSortedSet<T> toSortedSetBy(Function<? super T, ? extends V> function)
 
619
    {
 
620
        return this.getMutableCollection().toSortedSetBy(function);
 
621
    }
 
622
 
 
623
    public MutableSet<T> toSet()
 
624
    {
 
625
        return this.getMutableCollection().toSet();
 
626
    }
 
627
 
 
628
    public MutableBag<T> toBag()
 
629
    {
 
630
        return this.getMutableCollection().toBag();
 
631
    }
 
632
 
 
633
    public <NK, NV> MutableMap<NK, NV> toMap(
 
634
            Function<? super T, ? extends NK> keyFunction,
 
635
            Function<? super T, ? extends NV> valueFunction)
 
636
    {
 
637
        return this.getMutableCollection().toMap(keyFunction, valueFunction);
 
638
    }
 
639
 
 
640
    public <NK, NV> MutableSortedMap<NK, NV> toSortedMap(
 
641
            Function<? super T, ? extends NK> keyFunction,
 
642
            Function<? super T, ? extends NV> valueFunction)
 
643
    {
 
644
        return this.getMutableCollection().toSortedMap(keyFunction, valueFunction);
 
645
    }
 
646
 
 
647
    public <NK, NV> MutableSortedMap<NK, NV> toSortedMap(Comparator<? super NK> comparator,
 
648
            Function<? super T, ? extends NK> keyFunction,
 
649
            Function<? super T, ? extends NV> valueFunction)
 
650
    {
 
651
        return this.getMutableCollection().toSortedMap(comparator, keyFunction, valueFunction);
 
652
    }
 
653
 
 
654
    @Override
 
655
    public String toString()
 
656
    {
 
657
        return this.getMutableCollection().toString();
 
658
    }
 
659
 
 
660
    public String makeString()
 
661
    {
 
662
        return this.getMutableCollection().makeString();
 
663
    }
 
664
 
 
665
    public String makeString(String separator)
 
666
    {
 
667
        return this.getMutableCollection().makeString(separator);
 
668
    }
 
669
 
 
670
    public String makeString(String start, String separator, String end)
 
671
    {
 
672
        return this.getMutableCollection().makeString(start, separator, end);
 
673
    }
 
674
 
 
675
    public void appendString(Appendable appendable)
 
676
    {
 
677
        this.getMutableCollection().appendString(appendable);
 
678
    }
 
679
 
 
680
    public void appendString(Appendable appendable, String separator)
 
681
    {
 
682
        this.getMutableCollection().appendString(appendable, separator);
 
683
    }
 
684
 
 
685
    public void appendString(Appendable appendable, String start, String separator, String end)
 
686
    {
 
687
        this.getMutableCollection().appendString(appendable, start, separator, end);
 
688
    }
 
689
 
 
690
    public <V> MutableMultimap<V, T> groupBy(Function<? super T, ? extends V> function)
 
691
    {
 
692
        return this.getMutableCollection().groupBy(function);
 
693
    }
 
694
 
 
695
    public <V, R extends MutableMultimap<V, T>> R groupBy(
 
696
            Function<? super T, ? extends V> function,
 
697
            R target)
 
698
    {
 
699
        return this.getMutableCollection().groupBy(function, target);
 
700
    }
 
701
 
 
702
    public <V> MutableMultimap<V, T> groupByEach(Function<? super T, ? extends Iterable<V>> function)
 
703
    {
 
704
        return this.getMutableCollection().groupByEach(function);
 
705
    }
 
706
 
 
707
    public <V, R extends MutableMultimap<V, T>> R groupByEach(
 
708
            Function<? super T, ? extends Iterable<V>> function,
 
709
            R target)
 
710
    {
 
711
        return this.getMutableCollection().groupByEach(function, target);
 
712
    }
 
713
 
 
714
    public <V> MutableMap<V, T> groupByUniqueKey(Function<? super T, ? extends V> function)
 
715
    {
 
716
        throw new UnsupportedOperationException(this.getClass().getSimpleName() + ".groupByUniqueKey() not implemented yet");
 
717
    }
 
718
 
 
719
    public <S> MutableCollection<Pair<T, S>> zip(Iterable<S> that)
 
720
    {
 
721
        return this.getMutableCollection().zip(that);
 
722
    }
 
723
 
 
724
    public <S, R extends Collection<Pair<T, S>>> R zip(Iterable<S> that, R target)
 
725
    {
 
726
        return this.getMutableCollection().zip(that, target);
 
727
    }
 
728
 
 
729
    public MutableCollection<Pair<T, Integer>> zipWithIndex()
 
730
    {
 
731
        return this.getMutableCollection().zipWithIndex();
 
732
    }
 
733
 
 
734
    public <R extends Collection<Pair<T, Integer>>> R zipWithIndex(R target)
 
735
    {
 
736
        return this.getMutableCollection().zipWithIndex(target);
 
737
    }
 
738
 
 
739
    public RichIterable<RichIterable<T>> chunk(int size)
 
740
    {
 
741
        return this.getMutableCollection().chunk(size);
 
742
    }
 
743
 
 
744
    public MutableCollection<T> with(T element)
 
745
    {
 
746
        throw new UnsupportedOperationException("Cannot call with() on " + this.getClass().getSimpleName());
 
747
    }
 
748
 
 
749
    public MutableCollection<T> without(T element)
 
750
    {
 
751
        throw new UnsupportedOperationException("Cannot call without() on " + this.getClass().getSimpleName());
 
752
    }
 
753
 
 
754
    public MutableCollection<T> withAll(Iterable<? extends T> elements)
 
755
    {
 
756
        throw new UnsupportedOperationException("Cannot call withAll() on " + this.getClass().getSimpleName());
 
757
    }
 
758
 
 
759
    public MutableCollection<T> withoutAll(Iterable<? extends T> elements)
 
760
    {
 
761
        throw new UnsupportedOperationException("Cannot call withoutAll() on " + this.getClass().getSimpleName());
 
762
    }
 
763
 
 
764
    public <K, V> MutableMap<K, V> aggregateInPlaceBy(
 
765
            Function<? super T, ? extends K> groupBy,
 
766
            Function0<? extends V> zeroValueFactory,
 
767
            Procedure2<? super V, ? super T> mutatingAggregator)
 
768
    {
 
769
        MutableMap<K, V> map = UnifiedMap.newMap();
 
770
        this.forEach(new MutatingAggregationProcedure<T, K, V>(map, groupBy, zeroValueFactory, mutatingAggregator));
 
771
        return map;
 
772
    }
 
773
 
 
774
    public <K, V> MutableMap<K, V> aggregateBy(
 
775
            Function<? super T, ? extends K> groupBy,
 
776
            Function0<? extends V> zeroValueFactory,
 
777
            Function2<? super V, ? super T, ? extends V> nonMutatingAggregator)
 
778
    {
 
779
        MutableMap<K, V> map = UnifiedMap.newMap();
 
780
        this.forEach(new NonMutatingAggregationProcedure<T, K, V>(map, groupBy, zeroValueFactory, nonMutatingAggregator));
 
781
        return map;
 
782
    }
 
783
}