|
package swensen.functional;
/**
* A Tuple2 implementation representing a grouping by key
* @param <E> the element type
*/
public class Grouping<R,E> extends Tuple2<R,Seq<E>> {
public Grouping(R key, Seq<E> grouping) {
super(key, grouping);
}
/**
* Create a Grouping tuple from the given key (t1) and grouping (t2).
* @param key the grouping key
* @param grouping the grouping
* @param <R> the key type
* @param <E> the grouping type
* @return a new Grouping
*/
public static <R,E> Grouping<R,E> create(R key, Seq<E> grouping) {
return new Grouping(key,grouping);
}
/**
* A helper naming this.t1 as "key"
* @return this.t1
*/
public R getKey() {
return t1;
}
/**
* A helper naming this.t2 as "grouping"
* @return this.t2
*/
public Seq<E> getGrouping() {
return t2;
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
I'm developing Unquote, a library for writing unit test assertions as F# quoted expressions: http://code.google.com/p/unquote/
I am working through Project Euler with F#: http://projecteulerfun.blogspot.com/
I participate in Stack Overflow: http://stackoverflow.com/users/236255/stephen-swensen