Package civitas.celestis.util.tuple
Class Float2
java.lang.Object
civitas.celestis.util.tuple.Float2
- All Implemented Interfaces:
BaseTuple<Float>,FloatTuple,Serializable
An immutable type containing two primitive
floats.- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfloat[]array()Returns an array containing the components of this tuple in their proper order.boxed()Returns a tuple containing the components of this tuple in their boxed form.booleancontains(float v) Checks if this tuple contains the provided valuev.booleancontainsAll(Iterable<Float> i) Checks if this tuple contains multiple values.booleanChecks for equality between this tuple and the provided objectobj.floatget(int i) Returns theith component of this tuple.inthashCode()Returns the hash code of this instance.booleanisFinite()Returns whether this tuple is finite.booleanReturns whether this tuple is infinite.booleanisNaN()Returns whether this tuple containsFloat.NaN.booleanisZero()Returns whether this tuple represents zero.list()Returns an unmodifiable list containing the components of this tuple in their proper order.Applies the provided mapper functionfto each component of this tuple, then returns a new tuple containing the return values of the functionf.<F> Tuple<F>mapToObj(FloatFunction<? extends F> f) Applies the provided mapper functionfto each component of this tuple, then returns a new tuple containing the return values of the functionf.intsize()Returns the size of this tuple.stream()Returns a stream whose source is the elements of this tuple.toString()Serializes this tuple into a string.floatx()Returns the X component of this tuple.floaty()Returns the Y component of this tuple.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface civitas.celestis.util.tuple.FloatTuple
floatArray
-
Field Details
-
x
protected final float xThe X component of this tuple. -
y
protected final float yThe Y component of this tuple.
-
-
Constructor Details
-
Float2
public Float2(float x, float y) Creates a newFloat2.- Parameters:
x- The X component of this tupley- The Y component of this tuple
-
Float2
public Float2(@Nonnull float[] components) Creates a newFloat2.- Parameters:
components- An array containing the components of this tuple in XY order- Throws:
IllegalArgumentException- When the provided array's length is not2
-
Float2
Creates a newFloat2.- Parameters:
t- The tuple of which to copy component values from- Throws:
IllegalArgumentException- When the provided tuplet's size is not2
-
-
Method Details
-
size
public int size()Returns the size of this tuple. (the number of components it has)- Specified by:
sizein interfaceBaseTuple<Float>- Specified by:
sizein interfaceFloatTuple- 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:
isZeroin interfaceFloatTuple- Returns:
trueif every component of this tuple is zero
-
isNaN
public boolean isNaN()Returns whether this tuple containsFloat.NaN.- Specified by:
isNaNin interfaceFloatTuple- Returns:
trueif at least one component of this tuple is not a number- See Also:
-
isFinite
public boolean isFinite()Returns whether this tuple is finite.- Specified by:
isFinitein interfaceFloatTuple- Returns:
trueif every component of this tuple is finite- See Also:
-
isInfinite
public boolean isInfinite()Returns whether this tuple is infinite.- Specified by:
isInfinitein interfaceFloatTuple- Returns:
trueif at least one component of this tuple is infinite- See Also:
-
contains
public boolean contains(float v) Checks if this tuple contains the provided valuev.- Specified by:
containsin interfaceFloatTuple- Parameters:
v- The value of which to check for containment- Returns:
trueif at least one component of this tuple is equal to the provided valuev
-
containsAll
Checks if this tuple contains multiple values.- Specified by:
containsAllin interfaceFloatTuple- Parameters:
i- The iterable object of which to check for containment- Returns:
trueif this tuple contains every component of the iterable object
-
get
Returns theith component of this tuple.- Specified by:
getin interfaceFloatTuple- Parameters:
i- The index of the component to get- Returns:
- The
ith component of this tuple - Throws:
IndexOutOfBoundsException- When the indexiis out of bounds
-
x
public float x()Returns the X component of this tuple.- Returns:
- The X component of this tuple
-
y
public float y()Returns the Y component of this tuple.- Returns:
- The Y component of this tuple
-
map
Applies the provided mapper functionfto each component of this tuple, then returns a new tuple containing the return values of the functionf.- Specified by:
mapin interfaceFloatTuple- Parameters:
f- The function of which to apply to each component of this tuple- Returns:
- The resulting tuple
-
mapToObj
Applies the provided mapper functionfto each component of this tuple, then returns a new tuple containing the return values of the functionf.- Specified by:
mapToObjin interfaceFloatTuple- 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 float[] array()Returns an array containing the components of this tuple in their proper order.- Specified by:
arrayin interfaceFloatTuple- Returns:
- The array representation of this tuple
-
stream
Returns a stream whose source is the elements of this tuple.- Specified by:
streamin interfaceFloatTuple- Returns:
- A stream whose source is the elements of this tuple
- See Also:
-
list
Returns an unmodifiable list containing the components of this tuple in their proper order.- Specified by:
listin interfaceBaseTuple<Float>- Specified by:
listin interfaceFloatTuple- Returns:
- The list representation of this tuple
- See Also:
-
boxed
Returns a tuple containing the components of this tuple in their boxed form.- Specified by:
boxedin interfaceFloatTuple- Returns:
- The boxed object representation of this tuple
- See Also:
-
equals
Checks for equality between this tuple and the provided objectobj.- Specified by:
equalsin interfaceFloatTuple- Overrides:
equalsin classObject- Parameters:
obj- The object to compare to- Returns:
trueif the other object is also a float tuple, and the number of components, the order of the components, and the components' values are all equal
-
toString
Serializes this tuple into a string.- Specified by:
toStringin interfaceFloatTuple- Overrides:
toStringin classObject- Returns:
- The string representation of this tuple
-
hashCode
public int hashCode()Returns the hash code of this instance.
-