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

public final Class Booleans

extends Object
Class Inheritance
Annotations
@GwtCompatible
@ElementTypesAreNonnullByDefault
Static Imports
com.google.common.base.Preconditions.checkArgument, .Preconditions.checkElementIndex, .Preconditions.checkNotNull, .Preconditions.checkPositionIndexes

Static utility methods pertaining to boolean primitives, that are not already found in either Boolean 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 enum
Booleans.BooleanComparator

Comparators for Boolean values.

private static enum

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static List<Boolean>

Returns:

a list view of the array
asList
(boolean...
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:

a positive number if only a is true, a negative number if only b is true, or zero if a == b
compare
(boolean
the first boolean to compare
a
,
boolean
the second boolean to compare
b
)

Compares the two specified boolean values in the standard way (false is considered less than true).

public static boolean[]

Returns:

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

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

public static boolean

Returns:

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

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

public static int
countTrue(boolean... values)

Returns the number of values that are true.

public static boolean[]

Returns:

an array containing the values of array, with guaranteed minimum length minLength
ensureCapacity
(boolean[]
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 Comparator<Boolean>
falseFirst()

Returns a Comparator<Boolean> that sorts false before true.

public static int

Returns:

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

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

public static int

Returns:

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

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

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

public static int
indexOf(boolean[]
the array to search for the sequence target
array
,
boolean[]
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 String
join(String
the text that should appear between consecutive values in the resulting string (but not at the start or end)
separator
,
boolean...
an array of boolean values, possibly empty
array
)

Returns a string containing the supplied boolean values separated by separator.

public static int

Returns:

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

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

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

public static Comparator<boolean[]>
lexicographicalComparator()

Returns a comparator that compares two boolean arrays lexicographically.

public static void
reverse(boolean[] array)

Reverses the elements of array.

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

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

public static void
rotate(boolean[] 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(boolean[] array, int distance, int fromIndex, int toIndex)

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

public static boolean[]

Returns:

an array containing the same values as collection, in the same order, converted to primitives
toArray
(Collection<Boolean>
a collection of Boolean objects
collection
)

Copies a collection of Boolean instances into a new array of primitive boolean values.

public static Comparator<Boolean>
trueFirst()

Returns a Comparator<Boolean> that sorts true before false.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

Booleansback to summary
private Booleans()

Method Detail

asListback to summary
public static List<Boolean> asList(boolean... 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.

There are at most two distinct objects in this list, (Boolean) true and (Boolean) false. Java guarantees that those are always represented by the same objects.

The returned list is serializable.

Parameters
backingArray:boolean[]

the array to back the list

Returns:List<Boolean>

a list view of the array

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

Compares the two specified boolean values in the standard way (false is considered less than true). The sign of the value returned is the same as that of ((Boolean) a).compareTo(b).

Java 7+ users: this method should be treated as deprecated; use the equivalent Boolean#compare method instead.

Parameters
a:boolean

the first boolean to compare

b:boolean

the second boolean to compare

Returns:int

a positive number if only a is true, a negative number if only b is true, or zero if a == b

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

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

Parameters
arrays:boolean[][]

zero or more boolean arrays

Returns:boolean[]

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

containsback to summary
public static boolean contains(boolean[] array, boolean target)

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

Note

consider representing the array as a java.util.BitSet instead, replacing Booleans.contains(array, true) with !bitSet.isEmpty() and Booleans.contains(array, false) with bitSet.nextClearBit(0) == sizeOfBitSet.

Parameters
array:boolean[]

an array of boolean values, possibly empty

target:boolean

a primitive boolean value

Returns:boolean

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

countTrueback to summary
public static int countTrue(boolean... values)

Returns the number of values that are true.

Since
16.0
ensureCapacityback to summary
public static boolean[] ensureCapacity(boolean[] 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:boolean[]

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:boolean[]

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

Exceptions
IllegalArgumentException:
if minLength or padding is negative
falseFirstback to summary
public static Comparator<Boolean> falseFirst()

Returns a Comparator<Boolean> that sorts false before true.

This is particularly useful in Java 8+ in combination with Comparator.comparing, e.g. Comparator.comparing(Foo::hasBar, falseFirst()).

Since
21.0
hashCodeback to summary
public static int hashCode(boolean value)

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

Java 8+ users: use Boolean#hashCode(boolean) instead.

Parameters
value:boolean

a primitive boolean value

Returns:int

a hash code for the value

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

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

Note

consider representing the array as a java.util.BitSet instead, and using java.util.BitSet#nextSetBit(int) or java.util.BitSet#nextClearBit(int).

Parameters
array:boolean[]

an array of boolean values, possibly empty

target:boolean

a primitive boolean 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(boolean[] array, boolean target, int start, int end)
indexOfback to summary
public static int indexOf(boolean[] array, boolean[] 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.

Parameters
array:boolean[]

the array to search for the sequence target

target:boolean[]

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

joinback to summary
public static String join(String separator, boolean... array)

Returns a string containing the supplied boolean values separated by separator. For example, join("-", false, true, false) returns the string "false-true-false".

Parameters
separator:String

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

array:boolean[]

an array of boolean values, possibly empty

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

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

Parameters
array:boolean[]

an array of boolean values, possibly empty

target:boolean

a primitive boolean 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(boolean[] array, boolean target, int start, int end)
lexicographicalComparatorback to summary
public static Comparator<boolean[]> lexicographicalComparator()

Returns a comparator that compares two boolean arrays lexicographically. That is, it compares, using compare(boolean, boolean)), 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, [] < [false] < [false, true] < [true].

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

Since
2.0
reverseback to summary
public static void reverse(boolean[] array)

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

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

Reverses the elements of array between fromIndex inclusive and toIndex exclusive. This is equivalent to Collections.reverse(Booleans.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(boolean[] 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(Booleans.asList(array), distance), but is somewhat faster.

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

Since
32.0.0
rotateback to summary
public static void rotate(boolean[] 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(Booleans.asList(array).subList(fromIndex, toIndex), distance), but is somewhat faster.

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
toArrayback to summary
public static boolean[] toArray(Collection<Boolean> collection)

Copies a collection of Boolean instances into a new array of primitive boolean values.

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

Note

consider representing the collection as a java.util.BitSet instead.

Parameters
collection:Collection<Boolean>

a collection of Boolean objects

Returns:boolean[]

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
trueFirstback to summary
public static Comparator<Boolean> trueFirst()

Returns a Comparator<Boolean> that sorts true before false.

This is particularly useful in Java 8+ in combination with Comparator.comparing, e.g. Comparator.comparing(Foo::hasBar, trueFirst()).

Since
21.0
com.google.common.primitives back to summary

private Class Booleans.BooleanArrayAsList

extends AbstractList<Boolean>
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 boolean[]
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
BooleanArrayAsList(boolean[] array)

pack-priv
BooleanArrayAsList(boolean[] 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 Boolean
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 Boolean
set(int
index of the element to replace
index
,
Boolean
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<Boolean>
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 boolean[]
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 boolean[] 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

BooleanArrayAsListback to summary
pack-priv BooleanArrayAsList(boolean[] array)
BooleanArrayAsListback to summary
pack-priv BooleanArrayAsList(boolean[] 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 Boolean 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:Boolean

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 Boolean set(int index, Boolean 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:Boolean

Doc from java.util.List.set.

element to be stored at the specified position

Returns:Boolean

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<Boolean> 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<Boolean>

Doc from java.util.List.subList.

a view of the specified range within this list

Annotations
@Override
toBooleanArrayback to summary
pack-priv boolean[] toBooleanArray()
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 Enum Booleans.BooleanComparator

extends Enum<Booleans.BooleanComparator>
implements Comparator<Boolean>
Class Inheritance
All Implemented Interfaces
java.util.Comparator

Comparators for Boolean values.

Field Summary

Modifier and TypeField and Description
public static final Booleans.BooleanComparator
private final String
public static final Booleans.BooleanComparator
private final int

Constructor Summary

AccessConstructor and Description
private
BooleanComparator(int trueValue, String toString)

Method Summary

Modifier and TypeMethod and Description
public int
compare(Boolean
the first object to be compared.
a
,
Boolean
the second object to be compared.
b
)

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 Booleans.BooleanComparator
public static Booleans.BooleanComparator[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinalvalueOf

Field Detail

FALSE_FIRSTback to summary
public static final Booleans.BooleanComparator FALSE_FIRST
toStringback to summary
private final String toString
TRUE_FIRSTback to summary
public static final Booleans.BooleanComparator TRUE_FIRST
trueValueback to summary
private final int trueValue

Constructor Detail

BooleanComparatorback to summary
private BooleanComparator(int trueValue, String toString)

Method Detail

compareback to summary
public int compare(Boolean a, Boolean b)

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
a:Boolean

the first object to be compared.

b:Boolean

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 Booleans.BooleanComparator valueOf(String name)
valuesback to summary
public static Booleans.BooleanComparator[] values()
com.google.common.primitives back to summary

private final Enum Booleans.LexicographicalComparator

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

Field Summary

Modifier and TypeField and Description
public static final Booleans.LexicographicalComparator

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public int
compare(boolean[]
the first object to be compared.
left
,
boolean[]
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 Booleans.LexicographicalComparator
public static Booleans.LexicographicalComparator[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinalvalueOf

Field Detail

INSTANCEback to summary
public static final Booleans.LexicographicalComparator INSTANCE

Constructor Detail

LexicographicalComparatorback to summary
private LexicographicalComparator()

Method Detail

compareback to summary
public int compare(boolean[] left, boolean[] 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:boolean[]

the first object to be compared.

right:boolean[]

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 Booleans.LexicographicalComparator valueOf(String name)
valuesback to summary
public static Booleans.LexicographicalComparator[] values()