Class Tuples


  • public final class Tuples
    extends java.lang.Object
    Utility class for Tuple.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static Tuple fill​(java.lang.Object value, int length)
      Create a Tuple with all elements initialized to the same value.
      static Tuple intersection​(Tuple t1, Tuple t2)
      Set arithmetic: compute intersection of set of tuple elements in t1 and t2.
      static Tuple pairOperation​(Tuple t1, Tuple t2, java.util.function.BinaryOperator<java.lang.Object> fun)
      Apply fun to pairs of elements from t1 and t2.
      static Tuple subtract​(Tuple t1, Tuple t2)
      Set arithmetic: compute subtraction of set of tuple elements in t2 from elements in t1.
      static Tuple union​(Tuple t1, Tuple t2)
      Set arithmetic: compute union of set of tuple elements in t1 and t2.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • union

        public static Tuple union​(Tuple t1,
                                  Tuple t2)
        Set arithmetic: compute union of set of tuple elements in t1 and t2.
        Parameters:
        t1 - First tuple to union
        t2 - Second tuple to union
        Returns:
        a new tuple containing elements appearing in either tuple, in arbitrary order
      • intersection

        public static Tuple intersection​(Tuple t1,
                                         Tuple t2)
        Set arithmetic: compute intersection of set of tuple elements in t1 and t2.
        Parameters:
        t1 - First tuple to intersect
        t2 - Second tuple to intersect
        Returns:
        a new tuple containing elements appearing in both tuples, in arbitrary order
      • subtract

        public static Tuple subtract​(Tuple t1,
                                     Tuple t2)
        Set arithmetic: compute subtraction of set of tuple elements in t2 from elements in t1.
        Parameters:
        t1 - Base tuple
        t2 - Tuple to subtract
        Returns:
        a new tuple containing elements appearing in t1 but not t2, in arbitrary order
      • pairOperation

        public static Tuple pairOperation​(Tuple t1,
                                          Tuple t2,
                                          java.util.function.BinaryOperator<java.lang.Object> fun)
        Apply fun to pairs of elements from t1 and t2. If one tuple is longer, then its unmatched elements will be added to the output e.g., pairOperation([1,2,3],[4,5],max) -> [4,5,3]
        Parameters:
        t1 - Tuple of first arguments
        t2 - Tuple of second arguments
        fun - The function to apply to pairs of arguments
        Returns:
        a new tuple, such that the ith element is fun(t1.get(i),t2.get(i))
      • fill

        public static Tuple fill​(java.lang.Object value,
                                 int length)
        Create a Tuple with all elements initialized to the same value.
        Parameters:
        value - Value to which all elements will be initialized
        length - Size of the tuple
        Returns:
        a new tuple