object TupleOps
Implicits for converting tuples.
import com.twitter.conversions.TupleOps._ Seq(1 -> "tada", 2 -> "lala").toKeys Seq(1 -> "tada", 2 -> "lala").mapValues(_.size) Seq(1 -> "tada", 2 -> "lala").groupByKeyAndReduce(_ + "," + _) Seq(1 -> "tada", 2 -> "lala").sortByKey
- Alphabetic
- By Inheritance
- TupleOps
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Type Members
- implicit final class RichTuples[A, B] extends AnyVal
Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native()
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable])
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- def groupByKey[A, B](tuples: Iterable[(A, B)]): Map[A, Seq[B]]
Groups the tuples by matching the first element (key) in each tuple returning a map from the key to a seq of the according second elements.
Groups the tuples by matching the first element (key) in each tuple returning a map from the key to a seq of the according second elements.
For example:
groupByKey(Seq(1 -> "a", 1 -> "b", 2 -> "ab"))
will return Map(2 -> Seq("ab"), 1 -> Seq("a", "b"))
- tuples
the tuples or organize into a grouped map
- returns
a map of matching first elements to a sequence of their second elements
- def groupByKeyAndReduce[A, B](tuples: Iterable[(A, B)], reduceFunc: (B, B) => B): Map[A, B]
First groups the tuples by matching first elements creating a map of the first elements to a seq of the according second elements, then reduces the seq to a single value according to the applied
reduceFunc
.First groups the tuples by matching first elements creating a map of the first elements to a seq of the according second elements, then reduces the seq to a single value according to the applied
reduceFunc
.For example:
groupByKeyAndReduce(Seq(1 -> 5, 1 -> 6, 2 -> 7), _ + _)
will return Map(2 -> 7, 1 -> 11)
- tuples
the tuples or organize into a grouped map
- reduceFunc
the function to apply to the seq of second elements that have been grouped together
- returns
a map of matching first elements to a value after reducing the grouped values with the
reduceFunc
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- def mapValues[A, B, C](tuples: Iterable[(A, B)], func: (B) => C): Seq[(A, C)]
Applies
func
to the second element of each tuple.Applies
func
to the second element of each tuple.- tuples
the tuples to which the func is applied
- func
the function literal which will be applied to the second element of each tuple
- returns
a seq of
func
transformed tuples
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- def sortByKey[A, B](tuples: Iterable[(A, B)])(implicit ord: Ordering[A]): Seq[(A, B)]
Sorts the tuples by the first element in each tuple.
Sorts the tuples by the first element in each tuple.
- tuples
the tuples to sort
- ord
the order in which to sort the tuples
- returns
the sorted tuples
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toKeySet[A, B](tuples: Iterable[(A, B)]): Set[A]
Returns a new set of the first element of each tuple.
Returns a new set of the first element of each tuple.
- tuples
the tuples for which all the first elements will be returned
- returns
a set of the first element of each tuple
- def toKeys[A, B](tuples: Iterable[(A, B)]): Seq[A]
Returns a new seq of the first element of each tuple.
Returns a new seq of the first element of each tuple.
- tuples
the tuples for which all the first elements will be returned
- returns
a seq of the first element of each tuple
- def toSortedMap[A, B](tuples: Iterable[(A, B)])(implicit ord: Ordering[A]): SortedMap[A, B]
Sorts the tuples by the first element in each tuple and returns a SortedMap.
Sorts the tuples by the first element in each tuple and returns a SortedMap.
- tuples
the tuples to sort
- ord
the order in which to sort the tuples
- returns
a SortedMap of the tuples
- def toString(): String
- Definition Classes
- AnyRef → Any
- def toValues[A, B](tuples: Iterable[(A, B)]): Seq[B]
Returns a new seq of the second element of each tuple.
Returns a new seq of the second element of each tuple.
- tuples
the tuples for which all the second elements will be returned
- returns
a seq of the second element of each tuple
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()