Top Description Inners Fields Constructors Methods
com.google.common.primitives

public final Class Floats

extends FloatsMethodsForWeb
Class Inheritance
Annotations
@GwtCompatible
emulated:true
@ElementTypesAreNonnullByDefault
Static Imports
com.google.common.base.Preconditions.checkArgument, .Preconditions.checkElementIndex, .Preconditions.checkNotNull, .Preconditions.checkPositionIndexes, .Strings.lenientFormat, java.lang.Float.NEGATIVE_INFINITY, .Float.POSITIVE_INFINITY

Static utility methods pertaining to float primitives, that are not already found in either Float or Arrays.

See the Guava User Guide article on primitive utilities.

Author
Kevin Bourrillion
Since
1.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
private static class
private static enum

Field Summary

Modifier and TypeField and Description
public static final int
BYTES

The number of bytes required to represent a primitive float value.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static List<Float>

Returns:

a list view of the array
asList
(float...
the array to back the list
backingArray
)

Returns a fixed-size list backed by the specified array, similar to Arrays#asList(Object[]).

public static int

Returns:

the result of invoking Float#compare(float, float)
compare
(float
the first float to compare
a
,
float
the second float to compare
b
)

Compares the two specified float values using Float#compare(float, float).

public static float[]

Returns:

a single array containing all the values from the source arrays, in order
concat
(float[]...
zero or more float arrays
arrays
)

Returns the values from each provided array combined into a single array.

public static float
constrainToRange(float
the float value to constrain
value
,
float
the lower bound (inclusive) of the range to constrain value to
min
,
float
the upper bound (inclusive) of the range to constrain value to
max
)

Returns the value nearest to value which is within the closed range [min..max].

public static boolean

Returns:

true if array[i] == target for some value of i
contains
(float[]
an array of float values, possibly empty
array
,
float
a primitive float value
target
)

Returns true if target is present as an element anywhere in array.

public static float[]

Returns:

an array containing the values of array, with guaranteed minimum length minLength
ensureCapacity
(float[]
the source array
array
,
int
the minimum length the returned array must guarantee
minLength
,
int
an extra amount to "grow" the array by if growth is necessary
padding
)

Returns an array containing the same values as array, but guaranteed to be of a specified minimum length.

public static int

Returns:

a hash code for the value
hashCode
(float
a primitive float value
value
)

Returns a hash code for value; equal to the result of invoking ((Float) value).hashCode().

public static int

Returns:

the least index i for which array[i] == target, or -1 if no such index exists.
indexOf
(float[]
an array of float values, possibly empty
array
,
float
a primitive float value
target
)

Returns the index of the first appearance of the value target in array.

private static int
indexOf(float[] array, float target, int start, int end)

public static int
indexOf(float[]
the array to search for the sequence target
array
,
float[]
the array to search for as a sub-sequence of array
target
)

Returns the start position of the first occurrence of the specified target within array, or -1 if there is no such occurrence.

public static boolean
isFinite(float value)

Returns true if value represents a real number.

public static String
join(String
the text that should appear between consecutive values in the resulting string (but not at the start or end)
separator
,
float...
an array of float values, possibly empty
array
)

Returns a string containing the supplied float values, converted to strings as specified by Float#toString(float), and separated by separator.

public static int

Returns:

the greatest index i for which array[i] == target, or -1 if no such index exists.
lastIndexOf
(float[]
an array of float values, possibly empty
array
,
float
a primitive float value
target
)

Returns the index of the last appearance of the value target in array.

private static int
lastIndexOf(float[] array, float target, int start, int end)

public static Comparator<float[]>
lexicographicalComparator()

Returns a comparator that compares two float arrays lexicographically.

public static float

Returns:

the value present in array that is greater than or equal to every other value in the array
max
(float...
a nonempty array of float values
array
)

Returns the greatest value present in array, using the same rules of comparison as Math#max(float, float).

public static float

Returns:

the value present in array that is less than or equal to every other value in the array
min
(float...
a nonempty array of float values
array
)

Returns the least value present in array, using the same rules of comparison as Math#min(float, float).

public static void
reverse(float[] array)

Reverses the elements of array.

public static void
reverse(float[] array, int fromIndex, int toIndex)

Reverses the elements of array between fromIndex inclusive and toIndex exclusive.

public static void
rotate(float[] array, int distance)

Performs a right rotation of array of "distance" places, so that the first element is moved to index "distance", and the element at index i ends up at index (distance + i) mod array.length.

public static void
rotate(float[] array, int distance, int fromIndex, int toIndex)

Performs a right rotation of array between fromIndex inclusive and toIndex exclusive.

public static void
sortDescending(float[] array)

Sorts the elements of array in descending order.

public static void
sortDescending(float[] array, int fromIndex, int toIndex)

Sorts the elements of array between fromIndex inclusive and toIndex exclusive in descending order.

public static Converter<String, Float>
stringConverter()

Returns a serializable converter object that converts between strings and floats using Float#valueOf and Float#toString().

public static float[]

Returns:

an array containing the same values as collection, in the same order, converted to primitives
toArray
(Collection<? extends Number>
a collection of Number instances
collection
)

Returns an array containing each value of collection, converted to a float value in the manner of Number#floatValue.

public static Float

Returns:

the floating point value represented by string, or null if string has a length of zero or cannot be parsed as a float value
tryParse
(String
the string representation of a float value
string
)

Parses the specified string as a single-precision floating point value.

Field Detail

BYTESback to summary
public static final int BYTES

The number of bytes required to represent a primitive float value.

Java 8+ users: use Float#BYTES instead.

Since
10.0

Constructor Detail

Floatsback to summary
private Floats()

Method Detail

asListback to summary
public static List<Float> asList(float... backingArray)

Returns a fixed-size list backed by the specified array, similar to Arrays#asList(Object[]). The list supports List#set(int, Object), but any attempt to set a value to null will result in a NullPointerException.

The returned list maintains the values, but not the identities, of Float objects written to or read from it. For example, whether list.get(0) == list.get(0) is true for the returned list is unspecified.

The returned list may have unexpected behavior if it contains NaN, or if NaN is used as a parameter to any of its methods.

The returned list is serializable.

Parameters
backingArray:float[]

the array to back the list

Returns:List<Float>

a list view of the array

compareback to summary
public static int compare(float a, float b)

Compares the two specified float values using Float#compare(float, float). You may prefer to invoke that method directly; this method exists only for consistency with the other utilities in this package.

Note

this method simply delegates to the JDK method Float#compare. It is provided for consistency with the other primitive types, whose compare methods were not added to the JDK until JDK 7.

Parameters
a:float

the first float to compare

b:float

the second float to compare

Returns:int

the result of invoking Float#compare(float, float)

concatback to summary
public static float[] concat(float[]... arrays)

Returns the values from each provided array combined into a single array. For example, concat(new float[] {a, b}, new float[] {}, new float[] {c} returns the array {a, b, c}.

Parameters
arrays:float[][]

zero or more float arrays

Returns:float[]

a single array containing all the values from the source arrays, in order

constrainToRangeback to summary
public static float constrainToRange(float value, float min, float max)

Returns the value nearest to value which is within the closed range [min..max].

If value is within the range [min..max], value is returned unchanged. If value is less than min, min is returned, and if value is greater than max, max is returned.

Parameters
value:float

the float value to constrain

min:float

the lower bound (inclusive) of the range to constrain value to

max:float

the upper bound (inclusive) of the range to constrain value to

Exceptions
IllegalArgumentException:
if min > max
Since
21.0
containsback to summary
public static boolean contains(float[] array, float target)

Returns true if target is present as an element anywhere in array. Note that this always returns false when target is NaN.

Parameters
array:float[]

an array of float values, possibly empty

target:float

a primitive float value

Returns:boolean

true if array[i] == target for some value of i

ensureCapacityback to summary
public static float[] ensureCapacity(float[] array, int minLength, int padding)

Returns an array containing the same values as array, but guaranteed to be of a specified minimum length. If array already has a length of at least minLength, it is returned directly. Otherwise, a new array of size minLength + padding is returned, containing the values of array, and zeroes in the remaining places.

Parameters
array:float[]

the source array

minLength:int

the minimum length the returned array must guarantee

padding:int

an extra amount to "grow" the array by if growth is necessary

Returns:float[]

an array containing the values of array, with guaranteed minimum length minLength

Exceptions
IllegalArgumentException:
if minLength or padding is negative
hashCodeback to summary
public static int hashCode(float value)

Returns a hash code for value; equal to the result of invoking ((Float) value).hashCode().

Java 8+ users: use Float#hashCode(float) instead.

Parameters
value:float

a primitive float value

Returns:int

a hash code for the value

indexOfback to summary
public static int indexOf(float[] array, float target)

Returns the index of the first appearance of the value target in array. Note that this always returns -1 when target is NaN.

Parameters
array:float[]

an array of float values, possibly empty

target:float

a primitive float value

Returns:int

the least index i for which array[i] == target, or -1 if no such index exists.

indexOfback to summary
private static int indexOf(float[] array, float target, int start, int end)
indexOfback to summary
public static int indexOf(float[] array, float[] target)

Returns the start position of the first occurrence of the specified target within array, or -1 if there is no such occurrence.

More formally, returns the lowest index i such that Arrays.copyOfRange(array, i, i + target.length) contains exactly the same elements as target.

Note that this always returns -1 when target contains NaN.

Parameters
array:float[]

the array to search for the sequence target

target:float[]

the array to search for as a sub-sequence of array

isFiniteback to summary
public static boolean isFinite(float value)

Returns true if value represents a real number. This is equivalent to, but not necessarily implemented as, !(Float.isInfinite(value) || Float.isNaN(value)).

Java 8+ users: use Float#isFinite(float) instead.

Since
10.0
joinback to summary
public static String join(String separator, float... array)

Returns a string containing the supplied float values, converted to strings as specified by Float#toString(float), and separated by separator. For example, join("-", 1.0f, 2.0f, 3.0f) returns the string "1.0-2.0-3.0".

Note that Float#toString(float) formats float differently in GWT. In the previous example, it returns the string "1-2-3".

Parameters
separator:String

the text that should appear between consecutive values in the resulting string (but not at the start or end)

array:float[]

an array of float values, possibly empty

lastIndexOfback to summary
public static int lastIndexOf(float[] array, float target)

Returns the index of the last appearance of the value target in array. Note that this always returns -1 when target is NaN.

Parameters
array:float[]

an array of float values, possibly empty

target:float

a primitive float value

Returns:int

the greatest index i for which array[i] == target, or -1 if no such index exists.

lastIndexOfback to summary
private static int lastIndexOf(float[] array, float target, int start, int end)
lexicographicalComparatorback to summary
public static Comparator<float[]> lexicographicalComparator()

Returns a comparator that compares two float arrays lexicographically. That is, it compares, using compare(float, float)), the first pair of values that follow any common prefix, or when one array is a prefix of the other, treats the shorter array as the lesser. For example, [] < [1.0f] < [1.0f, 2.0f] < [2.0f].

The returned comparator is inconsistent with Object#equals(Object) (since arrays support only identity equality), but it is consistent with Arrays#equals(float[], float[]).

Since
2.0
maxback to summary
public static float max(float... array)

Returns the greatest value present in array, using the same rules of comparison as Math#max(float, float).

Parameters
array:float[]

a nonempty array of float values

Returns:float

the value present in array that is greater than or equal to every other value in the array

Annotations
@GwtIncompatible:Available in GWT! Annotation is to avoid conflict with GWT specialization of base class.
Exceptions
IllegalArgumentException:
if array is empty
minback to summary
public static float min(float... array)

Returns the least value present in array, using the same rules of comparison as Math#min(float, float).

Parameters
array:float[]

a nonempty array of float values

Returns:float

the value present in array that is less than or equal to every other value in the array

Annotations
@GwtIncompatible:Available in GWT! Annotation is to avoid conflict with GWT specialization of base class.
Exceptions
IllegalArgumentException:
if array is empty
reverseback to summary
public static void reverse(float[] array)

Reverses the elements of array. This is equivalent to Collections.reverse(Floats.asList(array)), but is likely to be more efficient.

Since
23.1
reverseback to summary
public static void reverse(float[] array, int fromIndex, int toIndex)

Reverses the elements of array between fromIndex inclusive and toIndex exclusive. This is equivalent to Collections.reverse(Floats.asList(array).subList(fromIndex, toIndex)), but is likely to be more efficient.

Exceptions
IndexOutOfBoundsException:
if fromIndex < 0, toIndex > array.length, or toIndex > fromIndex
Since
23.1
rotateback to summary
public static void rotate(float[] array, int distance)

Performs a right rotation of array of "distance" places, so that the first element is moved to index "distance", and the element at index i ends up at index (distance + i) mod array.length. This is equivalent to Collections.rotate(Floats.asList(array), distance), but is considerably faster and avoids allocation and garbage collection.

The provided "distance" may be negative, which will rotate left.

Since
32.0.0
rotateback to summary
public static void rotate(float[] array, int distance, int fromIndex, int toIndex)

Performs a right rotation of array between fromIndex inclusive and toIndex exclusive. This is equivalent to Collections.rotate(Floats.asList(array).subList(fromIndex, toIndex), distance), but is considerably faster and avoids allocations and garbage collection.

The provided "distance" may be negative, which will rotate left.

Exceptions
IndexOutOfBoundsException:
if fromIndex < 0, toIndex > array.length, or toIndex > fromIndex
Since
32.0.0
sortDescendingback to summary
public static void sortDescending(float[] array)

Sorts the elements of array in descending order.

Note that this method uses the total order imposed by Float#compare, which treats all NaN values as equal and 0.0 as greater than -0.0.

Since
23.1
sortDescendingback to summary
public static void sortDescending(float[] array, int fromIndex, int toIndex)

Sorts the elements of array between fromIndex inclusive and toIndex exclusive in descending order.

Note that this method uses the total order imposed by Float#compare, which treats all NaN values as equal and 0.0 as greater than -0.0.

Since
23.1
stringConverterback to summary
public static Converter<String, Float> stringConverter()

Returns a serializable converter object that converts between strings and floats using Float#valueOf and Float#toString().

Since
16.0
toArrayback to summary
public static float[] toArray(Collection<? extends Number> collection)

Returns an array containing each value of collection, converted to a float value in the manner of Number#floatValue.

Elements are copied from the argument collection as if by collection.toArray(). Calling this method is as thread-safe as calling that method.

Parameters
collection:Collection<? extends Number>

a collection of Number instances

Returns:float[]

an array containing the same values as collection, in the same order, converted to primitives

Exceptions
NullPointerException:
if collection or any of its elements is null
Since
1.0 (parameter was Collection<Float> before 12.0)
tryParseback to summary
public static Float tryParse(String string)

Parses the specified string as a single-precision floating point value. The ASCII character '-' ('\u002D') is recognized as the minus sign.

Unlike Float#parseFloat(String), this method returns null instead of throwing an exception if parsing fails. Valid inputs are exactly those accepted by Float#valueOf(String), except that leading and trailing whitespace is not permitted.

This implementation is likely to be faster than Float.parseFloat if many failures are expected.

Parameters
string:String

the string representation of a float value

Returns:Float

the floating point value represented by string, or null if string has a length of zero or cannot be parsed as a float value

Annotations
@GwtIncompatible
@CheckForNull
Exceptions
NullPointerException:
if string is null
Since
14.0
com.google.common.primitives back to summary

private Class Floats.FloatArrayAsList

extends AbstractList<Float>
implements RandomAccess, Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable, java.util.RandomAccess
Annotations
@GwtCompatible

Field Summary

Modifier and TypeField and Description
pack-priv final float[]
pack-priv final int
private static final long
pack-priv final int
Inherited from java.util.AbstractList:
modCount

Constructor Summary

AccessConstructor and Description
pack-priv
FloatArrayAsList(float[] array)

pack-priv
FloatArrayAsList(float[] array, int start, int end)

Method Summary

Modifier and TypeMethod and Description
public boolean
contains(Object
element whose presence in this list is to be tested
target
)

Overrides java.util.AbstractCollection.contains.

Implements java.util.List.contains, java.util.Collection.contains.

Returns true if this list contains the specified element.
public boolean
equals(Object
the object to be compared for equality with this list
object
)

Overrides java.util.AbstractList.equals.

Implements java.util.List.equals, java.util.Collection.equals.

Compares the specified object with this list for equality.
public Float
get(int
index of the element to return
index
)

Implements abstract java.util.AbstractList.get.

Implements java.util.List.get.

Returns the element at the specified position in this list.
public int
hashCode()

Overrides java.util.AbstractList.hashCode.

Implements java.util.List.hashCode, java.util.Collection.hashCode.

Returns the hash code value for this list.
public int
indexOf(Object
element to search for
target
)

Overrides java.util.AbstractList.indexOf.

Implements java.util.List.indexOf.

Returns the index of the first occurrence of the specified element in this list, or -1 if this list does not contain the element.
public boolean
isEmpty()

Overrides java.util.AbstractCollection.isEmpty.

Implements java.util.List.isEmpty, java.util.Collection.isEmpty.

Returns true if this list contains no elements.
public int
lastIndexOf(Object
element to search for
target
)

Overrides java.util.AbstractList.lastIndexOf.

Implements java.util.List.lastIndexOf.

Returns the index of the last occurrence of the specified element in this list, or -1 if this list does not contain the element.
public Float
set(int
index of the element to replace
index
,
Float
element to be stored at the specified position
element
)

Overrides java.util.AbstractList.set.

Implements java.util.List.set.

Replaces the element at the specified position in this list with the specified element (optional operation).
public int
size()

Implements abstract java.util.AbstractCollection.size.

Implements java.util.List.size, java.util.Collection.size.

Returns the number of elements in this list.
public List<Float>
subList(int
low endpoint (inclusive) of the subList
fromIndex
,
int
high endpoint (exclusive) of the subList
toIndex
)

Overrides java.util.AbstractList.subList.

Implements java.util.List.subList.

Returns a view of the portion of this list between the specified fromIndex, inclusive, and toIndex, exclusive.
pack-priv float[]
public String
toString()

Overrides java.util.AbstractCollection.toString.

Returns a string representation of this collection.
Inherited from java.util.AbstractList:
addaddaddAllcleariteratorlistIteratorlistIteratorremoveremoveRange

Field Detail

arrayback to summary
pack-priv final float[] array
endback to summary
pack-priv final int end
serialVersionUIDback to summary
private static final long serialVersionUID
startback to summary
pack-priv final int start

Constructor Detail

FloatArrayAsListback to summary
pack-priv FloatArrayAsList(float[] array)
FloatArrayAsListback to summary
pack-priv FloatArrayAsList(float[] array, int start, int end)

Method Detail

containsback to summary
public boolean contains(Object target)

Overrides java.util.AbstractCollection.contains.

Implements java.util.List.contains, java.util.Collection.contains.

Doc from java.util.List.contains.

Returns true if this list contains the specified element. More formally, returns true if and only if this list contains at least one element e such that Objects.equals(o, e).

Parameters
target:Object

element whose presence in this list is to be tested

Returns:boolean

true if this list contains the specified element

Annotations
@Override
equalsback to summary
public boolean equals(Object object)

Overrides java.util.AbstractList.equals.

Implements java.util.List.equals, java.util.Collection.equals.

Doc from java.util.AbstractList.equals.

Compares the specified object with this list for equality. Returns true if and only if the specified object is also a list, both lists have the same size, and all corresponding pairs of elements in the two lists are equal. (Two elements e1 and e2 are equal if (e1==null ? e2==null : e1.equals(e2)).) In other words, two lists are defined to be equal if they contain the same elements in the same order.

Parameters
object:Object

the object to be compared for equality with this list

Returns:boolean

true if the specified object is equal to this list

Annotations
@Override
getback to summary
public Float get(int index)

Implements abstract java.util.AbstractList.get.

Implements java.util.List.get.

Doc from java.util.AbstractList.get.

Returns the element at the specified position in this list.

Parameters
index:int

Doc from java.util.List.get.

index of the element to return

Returns:Float

Doc from java.util.List.get.

the element at the specified position in this list

Annotations
@Override
hashCodeback to summary
public int hashCode()

Overrides java.util.AbstractList.hashCode.

Implements java.util.List.hashCode, java.util.Collection.hashCode.

Doc from java.util.AbstractList.hashCode.

Returns the hash code value for this list.

Returns:int

the hash code value for this list

Annotations
@Override
indexOfback to summary
public int indexOf(Object target)

Overrides java.util.AbstractList.indexOf.

Implements java.util.List.indexOf.

Doc from java.util.AbstractList.indexOf.

Returns the index of the first occurrence of the specified element in this list, or -1 if this list does not contain the element. More formally, returns the lowest index i such that Objects.equals(o, get(i)), or -1 if there is no such index.

Parameters
target:Object

Doc from java.util.List.indexOf.

element to search for

Returns:int

Doc from java.util.List.indexOf.

the index of the first occurrence of the specified element in this list, or -1 if this list does not contain the element

Annotations
@Override
isEmptyback to summary
public boolean isEmpty()

Overrides java.util.AbstractCollection.isEmpty.

Implements java.util.List.isEmpty, java.util.Collection.isEmpty.

Doc from java.util.List.isEmpty.

Returns true if this list contains no elements.

Returns:boolean

true if this list contains no elements

Annotations
@Override
lastIndexOfback to summary
public int lastIndexOf(Object target)

Overrides java.util.AbstractList.lastIndexOf.

Implements java.util.List.lastIndexOf.

Doc from java.util.AbstractList.lastIndexOf.

Returns the index of the last occurrence of the specified element in this list, or -1 if this list does not contain the element. More formally, returns the highest index i such that Objects.equals(o, get(i)), or -1 if there is no such index.

Parameters
target:Object

Doc from java.util.List.lastIndexOf.

element to search for

Returns:int

Doc from java.util.List.lastIndexOf.

the index of the last occurrence of the specified element in this list, or -1 if this list does not contain the element

Annotations
@Override
setback to summary
public Float set(int index, Float element)

Overrides java.util.AbstractList.set.

Implements java.util.List.set.

Doc from java.util.AbstractList.set.

Replaces the element at the specified position in this list with the specified element (optional operation).

Parameters
index:int

Doc from java.util.List.set.

index of the element to replace

element:Float

Doc from java.util.List.set.

element to be stored at the specified position

Returns:Float

Doc from java.util.List.set.

the element previously at the specified position

Annotations
@Override
sizeback to summary
public int size()

Implements abstract java.util.AbstractCollection.size.

Implements java.util.List.size, java.util.Collection.size.

Doc from java.util.List.size.

Returns the number of elements in this list. If this list contains more than Integer.MAX_VALUE elements, returns Integer.MAX_VALUE.

Returns:int

the number of elements in this list

Annotations
@Override
subListback to summary
public List<Float> subList(int fromIndex, int toIndex)

Overrides java.util.AbstractList.subList.

Implements java.util.List.subList.

Doc from java.util.AbstractList.subList.

Returns a view of the portion of this list between the specified fromIndex, inclusive, and toIndex, exclusive. (If fromIndex and toIndex are equal, the returned list is empty.) The returned list is backed by this list, so non-structural changes in the returned list are reflected in this list, and vice-versa. The returned list supports all of the optional list operations supported by this list.

This method eliminates the need for explicit range operations (of the sort that commonly exist for arrays). Any operation that expects a list can be used as a range operation by passing a subList view instead of a whole list. For example, the following idiom removes a range of elements from a list:

list.subList(from, to).clear();
Similar idioms may be constructed for indexOf and lastIndexOf, and all of the algorithms in the Collections class can be applied to a subList.

The semantics of the list returned by this method become undefined if the backing list (i.e., this list) is structurally modified in any way other than via the returned list. (Structural modifications are those that change the size of this list, or otherwise perturb it in such a fashion that iterations in progress may yield incorrect results.)

Parameters
fromIndex:int

Doc from java.util.List.subList.

low endpoint (inclusive) of the subList

toIndex:int

Doc from java.util.List.subList.

high endpoint (exclusive) of the subList

Returns:List<Float>

Doc from java.util.List.subList.

a view of the specified range within this list

Annotations
@Override
toFloatArrayback to summary
pack-priv float[] toFloatArray()
toStringback to summary
public String toString()

Overrides java.util.AbstractCollection.toString.

Doc from java.util.AbstractCollection.toString.

Returns a string representation of this collection. The string representation consists of a list of the collection's elements in the order they are returned by its iterator, enclosed in square brackets ("[]"). Adjacent elements are separated by the characters ", " (comma and space). Elements are converted to strings as by String#valueOf(Object).

Returns:String

a string representation of this collection

Annotations
@Override
com.google.common.primitives back to summary

private final Class Floats.FloatConverter

extends Converter<String, Float>
implements Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable

Field Summary

Modifier and TypeField and Description
pack-priv static final Converter<String, Float>
private static final long

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
protected String
doBackward(Float
the instance to convert; will never be null
value
)

Implements abstract com.google.common.base.Converter.doBackward.

Returns a representation of b as an instance of type A.
protected Float
doForward(String
the instance to convert; will never be null
value
)

Implements abstract com.google.common.base.Converter.doForward.

Returns a representation of a as an instance of type B.
private Object
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from com.google.common.base.Converter:
andThenapplyconvertconvertAllequalsfromidentityreverse

Field Detail

INSTANCEback to summary
pack-priv static final Converter<String, Float> INSTANCE
serialVersionUIDback to summary
private static final long serialVersionUID

Constructor Detail

FloatConverterback to summary
private FloatConverter()

Method Detail

doBackwardback to summary
protected String doBackward(Float value)

Implements abstract com.google.common.base.Converter.doBackward.

Doc from com.google.common.base.Converter.doBackward.

Returns a representation of b as an instance of type A. If b cannot be converted, an unchecked exception (such as IllegalArgumentException) should be thrown.

Parameters
value:Float

the instance to convert; will never be null

Returns:String

the converted instance; must not be null

Annotations
@Override
doForwardback to summary
protected Float doForward(String value)

Implements abstract com.google.common.base.Converter.doForward.

Doc from com.google.common.base.Converter.doForward.

Returns a representation of a as an instance of type B. If a cannot be converted, an unchecked exception (such as IllegalArgumentException) should be thrown.

Parameters
value:String

the instance to convert; will never be null

Returns:Float

the converted instance; must not be null

Annotations
@Override
readResolveback to summary
private Object readResolve()
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object

Annotations
@Override
com.google.common.primitives back to summary

private final Enum Floats.LexicographicalComparator

extends Enum<Floats.LexicographicalComparator>
implements Comparator<float[]>
Class Inheritance
All Implemented Interfaces
java.util.Comparator

Field Summary

Modifier and TypeField and Description
public static final Floats.LexicographicalComparator

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public int
compare(float[]
the first object to be compared.
left
,
float[]
the second object to be compared.
right
)

Implements java.util.Comparator.compare.

Compares its two arguments for order.
public String
toString()

Overrides java.lang.Enum.toString.

Returns the name of this enum constant, as contained in the declaration.
public static Floats.LexicographicalComparator
public static Floats.LexicographicalComparator[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinalvalueOf

Field Detail

INSTANCEback to summary
public static final Floats.LexicographicalComparator INSTANCE

Constructor Detail

LexicographicalComparatorback to summary
private LexicographicalComparator()

Method Detail

compareback to summary
public int compare(float[] left, float[] right)

Implements java.util.Comparator.compare.

Doc from java.util.Comparator.compare.

Compares its two arguments for order. Returns a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.

The implementor must ensure that signum(compare(x, y)) == -signum(compare(y, x)) for all x and y. (This implies that compare(x, y) must throw an exception if and only if compare(y, x) throws an exception.)

The implementor must also ensure that the relation is transitive: ((compare(x, y)>0) && (compare(y, z)>0)) implies compare(x, z)>0.

Finally, the implementor must ensure that compare(x, y)==0 implies that signum(compare(x, z))==signum(compare(y, z)) for all z.

Parameters
left:float[]

the first object to be compared.

right:float[]

the second object to be compared.

Returns:int

a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Enum.toString.

Doc from java.lang.Enum.toString.

Returns the name of this enum constant, as contained in the declaration. This method may be overridden, though it typically isn't necessary or desirable. An enum class should override this method when a more "programmer-friendly" string form exists.

Returns:String

the name of this enum constant

Annotations
@Override
valueOfback to summary
public static Floats.LexicographicalComparator valueOf(String name)
valuesback to summary
public static Floats.LexicographicalComparator[] values()