-
Notifications
You must be signed in to change notification settings - Fork 275
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[GSCOLLECT-411] Implement SortedBag.
git-svn-id: svn+ssh://gscollections.svn.services.gs.com/svnroot/gscollections-svn/trunk@430 d5c9223b-1aff-41ac-aadd-f810b4a99ac4
- Loading branch information
Kristen O'Leary
committed
Oct 16, 2013
1 parent
2a21442
commit a28a7ee
Showing
48 changed files
with
5,648 additions
and
664 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
collections-api/src/main/java/com/gs/collections/api/bag/sorted/ImmutableSortedBag.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/* | ||
* 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.bag.sorted; | ||
|
||
import com.gs.collections.api.bag.ImmutableBag; | ||
import com.gs.collections.api.block.function.Function; | ||
import com.gs.collections.api.block.predicate.Predicate; | ||
import com.gs.collections.api.block.predicate.primitive.IntPredicate; | ||
import com.gs.collections.api.multimap.sortedbag.ImmutableSortedBagMultimap; | ||
import com.gs.collections.api.partition.bag.sorted.PartitionImmutableSortedBag; | ||
import net.jcip.annotations.Immutable; | ||
|
||
/** | ||
* ImmutableSortedBag is the non-modifiable equivalent interface to {@link MutableSortedBag}. | ||
* | ||
* @since 4.2 | ||
*/ | ||
@Immutable | ||
public interface ImmutableSortedBag<T> | ||
extends ImmutableBag<T>, SortedBag<T> | ||
{ | ||
ImmutableSortedBag<T> newWith(T element); | ||
|
||
ImmutableSortedBag<T> newWithout(T element); | ||
|
||
ImmutableSortedBag<T> newWithAll(Iterable<? extends T> elements); | ||
|
||
ImmutableSortedBag<T> newWithoutAll(Iterable<? extends T> elements); | ||
|
||
ImmutableSortedBag<T> selectByOccurrences(IntPredicate predicate); | ||
|
||
ImmutableSortedBag<T> select(Predicate<? super T> predicate); | ||
|
||
ImmutableSortedBag<T> reject(Predicate<? super T> predicate); | ||
|
||
PartitionImmutableSortedBag<T> partition(Predicate<? super T> predicate); | ||
|
||
<S> ImmutableSortedBag<S> selectInstancesOf(Class<S> clazz); | ||
|
||
<V> ImmutableSortedBagMultimap<V, T> groupBy(Function<? super T, ? extends V> function); | ||
|
||
<V> ImmutableSortedBagMultimap<V, T> groupByEach(Function<? super T, ? extends Iterable<V>> function); | ||
|
||
//Not yet supported | ||
|
||
//<S> ImmutableBag<Pair<T, S>> zip(Iterable<S> that); | ||
|
||
//ImmutableBag<Pair<T, Integer>> zipWithIndex(); | ||
|
||
// <K, V> SortedMapIterable<K, V> aggregateInPlaceBy( | ||
// Function<? super T, ? extends K> groupBy, | ||
// Function0<? extends V> zeroValueFactory, | ||
// Procedure2<? super V, ? super T> mutatingAggregator); | ||
// | ||
// <K, V> SortedMapIterable<K, V> aggregateBy( | ||
// Function<? super T, ? extends K> groupBy, | ||
// Function0<? extends V> zeroValueFactory, | ||
// Function2<? super V, ? super T, ? extends V> nonMutatingAggregator); | ||
} |
85 changes: 85 additions & 0 deletions
85
collections-api/src/main/java/com/gs/collections/api/bag/sorted/MutableSortedBag.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
/* | ||
* 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.bag.sorted; | ||
|
||
import com.gs.collections.api.bag.MutableBag; | ||
import com.gs.collections.api.block.function.Function; | ||
import com.gs.collections.api.block.predicate.Predicate; | ||
import com.gs.collections.api.block.predicate.Predicate2; | ||
import com.gs.collections.api.block.predicate.primitive.IntPredicate; | ||
import com.gs.collections.api.multimap.sortedbag.MutableSortedBagMultimap; | ||
import com.gs.collections.api.partition.bag.sorted.PartitionMutableSortedBag; | ||
|
||
/** | ||
* @since 4.2 | ||
*/ | ||
public interface MutableSortedBag<T> | ||
extends SortedBag<T>, MutableBag<T>, Cloneable | ||
{ | ||
MutableSortedBag<T> selectByOccurrences(IntPredicate predicate); | ||
|
||
MutableSortedBag<T> with(T element); | ||
|
||
MutableSortedBag<T> without(T element); | ||
|
||
MutableSortedBag<T> withAll(Iterable<? extends T> elements); | ||
|
||
MutableSortedBag<T> withoutAll(Iterable<? extends T> elements); | ||
|
||
MutableSortedBag<T> newEmpty(); | ||
|
||
<P> MutableSortedBag<T> selectWith(Predicate2<? super T, ? super P> predicate, P parameter); | ||
|
||
<P> MutableSortedBag<T> rejectWith(Predicate2<? super T, ? super P> predicate, P parameter); | ||
|
||
/** | ||
* Returns an unmodifable view of the set. The returned set will be <tt>Serializable</tt> if this set is <tt>Serializable</tt>. | ||
* | ||
* @return an unmodifiable view of this set | ||
*/ | ||
MutableSortedBag<T> asUnmodifiable(); | ||
|
||
MutableSortedBag<T> asSynchronized(); | ||
|
||
MutableSortedBag<T> reject(Predicate<? super T> predicate); | ||
|
||
<V> MutableSortedBagMultimap<V, T> groupBy(Function<? super T, ? extends V> function); | ||
|
||
MutableSortedBag<T> select(Predicate<? super T> predicate); | ||
|
||
PartitionMutableSortedBag<T> partition(Predicate<? super T> predicate); | ||
|
||
<S> MutableSortedBag<S> selectInstancesOf(Class<S> clazz); | ||
|
||
<V> MutableSortedBagMultimap<V, T> groupByEach(Function<? super T, ? extends Iterable<V>> function); | ||
|
||
// Not yet supported | ||
// <S> MutableBag<Pair<T, S>> zip(Iterable<S> that); | ||
// | ||
// MutableBag<Pair<T, Integer>> zipWithIndex(); | ||
// | ||
// <K, V> SortedMapIterable<K, V> aggregateInPlaceBy( | ||
// Function<? super T, ? extends K> groupBy, | ||
// Function0<? extends V> zeroValueFactory, | ||
// Procedure2<? super V, ? super T> mutatingAggregator); | ||
// | ||
// <K, V> SortedMapIterable<K, V> aggregateBy( | ||
// Function<? super T, ? extends K> groupBy, | ||
// Function0<? extends V> zeroValueFactory, | ||
// Function2<? super V, ? super T, ? extends V> nonMutatingAggregator); | ||
// MutableSortedMap<T, Integer> toMapOfItemToCount(); | ||
} |
Oops, something went wrong.