Class Tuple

    • Constructor Detail

      • Tuple

        public Tuple()
    • Method Detail

      • appendLeft

        public <T> Tuple appendLeft​(T object)
        Appends an item the beginning of the tuple resulting in a new tuple of degree + 1
        Type Parameters:
        T - the type parameter
        Parameters:
        object - the object being appended
        Returns:
        A new tuple of degree + 1 containing the object at the beginning
      • appendRight

        public <T> Tuple appendRight​(T object)
        Appends an item the end of the tuple resulting in a new tuple of degree + 1
        Type Parameters:
        T - the type parameter
        Parameters:
        object - the object being appended
        Returns:
        A new tuple of degree + 1 containing the object at the end
      • array

        public abstract Object[] array()
        The tuple as an array of objects
        Returns:
        an array representing the items in the tuple
      • degree

        public abstract int degree()
        The number of items in the tuple
        Returns:
        the number of items in the tuple
      • equals

        public final boolean equals​(Object obj)
        Overrides:
        equals in class Object
      • get

        public <T> T get​(int i)
        Gets the ith item of the tuple.
        Type Parameters:
        T - the type parameter
        Parameters:
        i - the index of the item
        Returns:
        the item at the ith index
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • map

        public <R> R map​(@NonNull
                         @NonNull Function<Tuple,​R> function)
        Maps the tuple to another a data type.
        Type Parameters:
        R - the type being mapped to
        Parameters:
        function - the mapping function
        Returns:
        the result of the mapping function
      • mapValues

        public Tuple mapValues​(@NonNull
                               @NonNull Function<Object,​?> function)
        Maps the values of the tuple to another data type
        Parameters:
        function - the mapping function
        Returns:
        A new tuple of same degree whose values are the result of the mapping function applied to the this tuple's elements.
      • shiftLeft

        public Tuple shiftLeft()
        Shifts the first element of the tuple resulting in a tuple of degree - 1.
        Returns:
        A new tuple without the shifted element;
      • shiftRight

        public Tuple shiftRight()
        Shifts the last element of the tuple resulting in a tuple of degree - 1.
        Returns:
        A new tuple without the shifted element;
      • slice

        public Tuple slice​(int start,
                           int end)
        Takes a slice of the tuple from an inclusive start to an exclusive end index.
        Parameters:
        start - Where to start the slice from (inclusive)
        end - Where to end the slice at (exclusive)
        Returns:
        A new tuple of degree (end - start) with the elements of this tuple from start to end
      • stream

        public Stream<Object> stream()
        Gets a stream over the objects in the tuple
        Returns:
        A Stream of the objects in the tuple