Packages

object TupleOps

Implicits for converting tuples.

Example:
  1. 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
Linear Supertypes
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. TupleOps
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Type Members

  1. implicit final class RichTuples[A, B] extends AnyVal

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##: Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  5. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @native()
  6. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  7. def equals(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef → Any
  8. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.Throwable])
  9. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  10. 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

  11. 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

  12. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  13. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  14. 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

  15. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  16. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  17. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  18. 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

  19. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  20. 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

  21. 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

  22. 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

  23. def toString(): String
    Definition Classes
    AnyRef → Any
  24. 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

  25. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  26. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  27. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()

Inherited from AnyRef

Inherited from Any

Ungrouped