Class Int1

java.lang.Object
civitas.celestis.util.tuple.Int1
All Implemented Interfaces:
BaseTuple<Integer>, IntTuple, Serializable

public class Int1 extends Object implements IntTuple
A tuple with one element.
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final int
    The element of this tuple.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Int1(int element)
    Creates a new tuple.
    Int1(int[] elements)
    Creates a new tuple.
    Creates a new tuple.
  • Method Summary

    Modifier and Type
    Method
    Description
    int[]
    Returns an array containing the components of this tuple in their proper order.
    Returns a tuple containing the components of this tuple in their boxed form.
    boolean
    contains(int v)
    Checks if this tuple contains the provided value v.
    boolean
    Checks if this tuple contains multiple values.
    boolean
    Checks for equality between this tuple and the provided object obj.
    int
    get()
    Returns the element of this tuple.
    int
    get(int i)
    Returns the ith component of this tuple.
    int
    Returns the hash code of this instance.
    boolean
    Returns whether this tuple represents zero.
    Returns an unmodifiable list containing the components of this tuple in their proper order.
    Applies the provided mapper function f to each component of this tuple, then returns a new tuple containing the return values of the function f.
    <F> Tuple<F>
    mapToObj(IntFunction<? extends F> f)
    Applies the provided mapper function f to each component of this tuple, then returns a new tuple containing the return values of the function f.
    int
    Returns the size of this tuple.
    Returns a stream whose source is the elements of this tuple.
    Serializes this tuple into a string.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait

    Methods inherited from interface civitas.celestis.util.tuple.IntTuple

    intArray
  • Field Details

    • element

      protected final int element
      The element of this tuple.
  • Constructor Details

    • Int1

      public Int1(int element)
      Creates a new tuple.
      Parameters:
      element - The element of this tuple
    • Int1

      public Int1(@Nonnull int[] elements)
      Creates a new tuple.
      Parameters:
      elements - The singular array of this tuple's element
      Throws:
      IllegalArgumentException - When the provided array's length is not 1
    • Int1

      public Int1(@Nonnull IntTuple t)
      Creates a new tuple.
      Parameters:
      t - The tuple of which to copy elements from
      Throws:
      IllegalArgumentException - When the provided tuple t's size is not 1
  • Method Details

    • size

      public int size()
      Returns the size of this tuple. (the number of components it has)
      Specified by:
      size in interface BaseTuple<Integer>
      Specified by:
      size in interface IntTuple
      Returns:
      The number of components this tuple has
    • isZero

      public boolean isZero()
      Returns whether this tuple represents zero. (whether every component is zero)
      Specified by:
      isZero in interface IntTuple
      Returns:
      true if every component of this tuple is zero
    • contains

      public boolean contains(int v)
      Checks if this tuple contains the provided value v.
      Specified by:
      contains in interface IntTuple
      Parameters:
      v - The value of which to check for containment
      Returns:
      true if at least one component of this tuple is equal to the provided value v
    • containsAll

      public boolean containsAll(@Nonnull Iterable<Integer> i)
      Checks if this tuple contains multiple values.
      Specified by:
      containsAll in interface IntTuple
      Parameters:
      i - The iterable object of which to check for containment
      Returns:
      true if this tuple contains every component of the iterable object
    • get

      public int get(int i) throws IndexOutOfBoundsException
      Returns the ith component of this tuple.
      Specified by:
      get in interface IntTuple
      Parameters:
      i - The index of the element to get
      Returns:
      The ith component of this tuple
      Throws:
      IndexOutOfBoundsException - When the index i is out of bounds
    • get

      public int get()
      Returns the element of this tuple.
      Returns:
      The element of this tuple
    • map

      @Nonnull public IntTuple map(@Nonnull IntUnaryOperator f)
      Applies the provided mapper function f to each component of this tuple, then returns a new tuple containing the return values of the function f.
      Specified by:
      map in interface IntTuple
      Parameters:
      f - The function of which to apply to each component of this tuple
      Returns:
      The resulting tuple
    • mapToObj

      @Nonnull public <F> Tuple<F> mapToObj(@Nonnull IntFunction<? extends F> f)
      Applies the provided mapper function f to each component of this tuple, then returns a new tuple containing the return values of the function f.
      Specified by:
      mapToObj in interface IntTuple
      Type Parameters:
      F - The type of component to map this tuple to
      Parameters:
      f - The function of which to apply to each component of this tuple
      Returns:
      The resulting tuple
    • array

      @Nonnull public int[] array()
      Returns an array containing the components of this tuple in their proper order.
      Specified by:
      array in interface IntTuple
      Returns:
      The array representation of this tuple
    • stream

      @Nonnull public IntStream stream()
      Returns a stream whose source is the elements of this tuple.
      Specified by:
      stream in interface IntTuple
      Returns:
      A stream whose source is the elements of this tuple
      See Also:
    • list

      @Nonnull public List<Integer> list()
      Returns an unmodifiable list containing the components of this tuple in their proper order.
      Specified by:
      list in interface BaseTuple<Integer>
      Specified by:
      list in interface IntTuple
      Returns:
      The list representation of this tuple
      See Also:
    • boxed

      @Nonnull public Tuple<Integer> boxed()
      Returns a tuple containing the components of this tuple in their boxed form.
      Specified by:
      boxed in interface IntTuple
      Returns:
      The boxed object representation of this tuple
      See Also:
    • equals

      public boolean equals(@Nullable Object obj)
      Checks for equality between this tuple and the provided object obj.
      Specified by:
      equals in interface IntTuple
      Overrides:
      equals in class Object
      Parameters:
      obj - The object to compare to
      Returns:
      true if the other object is also an integer tuple, and the number of components, the order of the components, and the components' values are all equal
    • toString

      @Nonnull public String toString()
      Serializes this tuple into a string.
      Specified by:
      toString in interface IntTuple
      Overrides:
      toString in class Object
      Returns:
      The string representation of this tuple
    • hashCode

      public int hashCode()
      Returns the hash code of this instance.
      Overrides:
      hashCode in class Object
      Returns:
      The hash code of this instance