public class Sequences
extends java.lang.Object
A sequence is an Iterable
which is expected to provide the same sequence of
items in the same order. E.g. a HashSet
and a SortedSet
provide different sequences, even if they contain the same elements.
Modifier and Type | Field and Description |
---|---|
static java.util.function.BiPredicate<java.lang.Object,java.lang.Object> |
IDENTICAL
Are two objects identical?
|
Modifier and Type | Method and Description |
---|---|
static boolean |
areEqual(java.lang.Iterable<?> seq1,
java.lang.Iterable<?> seq2)
Are two sequences equal in the standard Java definition of equality?
|
static <T1,T2> boolean |
areEqual(java.lang.Iterable<T1> seq1,
java.lang.Iterable<T2> seq2,
java.util.function.BiPredicate<? super T1,? super T2> equality)
Are two sequences equal?
|
static boolean |
areEqual(java.util.Iterator<?> it1,
java.util.Iterator<?> it2)
Do two iterators provide the same sequence, using the standard Java definition of equality?
|
static <T1,T2> boolean |
areEqual(java.util.Iterator<T1> it1,
java.util.Iterator<T2> it2,
java.util.function.BiPredicate<? super T1,? super T2> equality)
Do two iterators provide the same sequence?
|
static <T1,T2> boolean |
areEqual(T1[] arr1,
int start1,
int len1,
T2[] arr2,
int start2,
int len2,
java.util.function.BiPredicate<? super T1,? super T2> equality)
Are parts of two arrays equal?
|
static <T1,T2> boolean |
areEqual(T1[] arr1,
T2[] arr2,
java.util.function.BiPredicate<? super T1,? super T2> equality)
Are two arrays equal?
|
static boolean |
areIdentical(java.lang.Iterable<?> seq1,
java.lang.Iterable<?> seq2)
Are two sequences equal in the standard Java definition of equality?
|
static boolean |
areIdentical(java.util.Iterator<?> it1,
java.util.Iterator<?> it2)
Do two iterators provide the same sequence, using the standard Java definition of equality?
|
static <T extends java.lang.Comparable<T>> |
compare(java.lang.Iterable<? extends T> seq1,
java.lang.Iterable<? extends T> seq2)
Compare two sequences of comparable elements and return the result.
|
static <T extends java.lang.Comparable<T>> |
compare(java.lang.Iterable<? extends T> seq1,
java.lang.Iterable<? extends T> seq2,
Order longerOrder)
Compare two sequences of comparable elements and return the result.
|
static <T> Order |
compare(java.lang.Iterable<? extends T> seq1,
java.lang.Iterable<? extends T> seq2,
Ordering<? super T> ordering)
Compare two sequences and return the result.
|
static <T> Order |
compare(java.lang.Iterable<? extends T> seq1,
java.lang.Iterable<? extends T> seq2,
Order longerOrder,
Ordering<? super T> ordering)
Compare two sequences and return the result.
|
static <T extends java.lang.Comparable<T>> |
compare(java.util.Iterator<? extends T> it1,
java.util.Iterator<? extends T> it2)
Compare the iterators of two sequences and return the result.
|
static <T extends java.lang.Comparable<T>> |
compare(java.util.Iterator<? extends T> it1,
java.util.Iterator<? extends T> it2,
Order longerOrder)
Compare the iterators of two sequences of comparable elements and return the result.
|
static <T> Order |
compare(java.util.Iterator<? extends T> it1,
java.util.Iterator<? extends T> it2,
Ordering<? super T> ordering)
Compare the iterators of two sequences and return the result.
|
static <T> Order |
compare(java.util.Iterator<? extends T> it1,
java.util.Iterator<? extends T> it2,
Order longerOrder,
Ordering<? super T> ordering)
Compare the iterators of two sequences and return the result.
|
public static final java.util.function.BiPredicate<java.lang.Object,java.lang.Object> IDENTICAL
e1 == e2
into a bi-predicate.public static boolean areEqual(@NotNull java.lang.Iterable<?> seq1, @NotNull java.lang.Iterable<?> seq2)
Objects.deepEquals(Object, Object)
as equality definition.
Two sequences with different lengths are always considered unequal.
This method deliberately allows comparison of sequences of different types.
seq1
- first sequenceseq2
- second sequencetrue
if both sequences are considered equalfalse
if they are considered unequalpublic static boolean areEqual(@NotNull java.util.Iterator<?> it1, @NotNull java.util.Iterator<?> it2)
Objects.deepEquals(Object, Object)
.
Two sequences with different lengths are always considered unequal.
This method deliberately allows comparison of sequences of different types.
The iterators used as parameters will be both exhausted if this method returns true
.
Otherwise, they will stand at the first inequality, which can mean that one is exhausted
while the other is not.
it1
- iterator over the first sequenceit2
- iterator over the second sequencetrue
if both sequences are considered equalfalse
if they are considered unequalpublic static boolean areIdentical(@NotNull java.lang.Iterable<?> seq1, @NotNull java.lang.Iterable<?> seq2)
Objects.equals(Object, Object)
as equality definition.
Two sequences with different lengths are always considered unequal.
This method deliberately allows comparison of sequences of different types.
seq1
- first sequenceseq2
- second sequencetrue
if both sequences are considered equalfalse
if they are considered unequalpublic static boolean areIdentical(@NotNull java.util.Iterator<?> it1, @NotNull java.util.Iterator<?> it2)
Objects.equals(Object, Object)
.
Two sequences with different lengths are always considered unequal.
This method deliberately allows comparison of sequences of different types.
The iterators used as parameters will be both exhausted if this method returns true
.
Otherwise, they will stand at the first inequality, which can mean that one is exhausted
while the other is not.
it1
- iterator over the first sequenceit2
- iterator over the second sequencetrue
if both sequences are considered equalfalse
if they are considered unequalpublic static <T1,T2> boolean areEqual(@NotNull java.lang.Iterable<T1> seq1, @NotNull java.lang.Iterable<T2> seq2, @NotNull java.util.function.BiPredicate<? super T1,? super T2> equality)
This method deliberately allows comparison of sequences of different types.
T1
- element type of first sequenceT2
- element type of second sequenceseq1
- first sequenceseq2
- second sequenceequality
- element equality definition, has to return true
for elements considered,
and false
for elements considered unequaltrue
if both sequences are considered equalfalse
if they are considered unequalpublic static <T1,T2> boolean areEqual(@NotNull T1[] arr1, @NotNull T2[] arr2, @NotNull java.util.function.BiPredicate<? super T1,? super T2> equality)
This method deliberately allows comparison of arrays of different types.
T1
- element type of first arrayT2
- element type of second arrayarr1
- first arrayarr2
- second arrayequality
- element equality definition, has to return true
for elements considered,
and false
for elements considered unequaltrue
if both sequences are considered equalfalse
if they are considered unequalpublic static <T1,T2> boolean areEqual(@NotNull T1[] arr1, int start1, int len1, @NotNull T2[] arr2, int start2, int len2, @NotNull java.util.function.BiPredicate<? super T1,? super T2> equality)
This method deliberately allows comparison of arrays of different types.
T1
- element type of first arrayT2
- element type of second arrayarr1
- first arraystart1
- index of the first relevant element in the first arraylen1
- number of relevant elements in the first arrayarr2
- second arraystart2
- index of the first relevant element in the second arraylen2
- number of relevant elements in the second arrayequality
- element equality definition, has to return true
for elements considered,
and false
for elements considered unequaltrue
if both intervals are considered equalfalse
if they are considered unequalpublic static <T1,T2> boolean areEqual(@NotNull java.util.Iterator<T1> it1, @NotNull java.util.Iterator<T2> it2, @NotNull java.util.function.BiPredicate<? super T1,? super T2> equality)
This method deliberately allows comparison of sequences of different types.
The iterators used as parameters will be both exhausted if this method returns true
.
Otherwise, they will stand at the first inequality, which can mean that one is exhausted
while the other is not.
T1
- element type of first sequenceT2
- element type of second sequenceit1
- iterator over the first sequenceit2
- iterator over the second sequenceequality
- element equality definition, has to return true
for elements considered,
and false
for elements considered unequaltrue
if both sequences are considered equalfalse
if they are considered unequal@NotNull public static <T extends java.lang.Comparable<T>> Order compare(@NotNull java.lang.Iterable<? extends T> seq1, @NotNull java.lang.Iterable<? extends T> seq2)
T
- common (super) element type of both sequencesseq1
- first sequenceseq2
- second sequenceOrder
enum value describing the order of both sequences@NotNull public static <T extends java.lang.Comparable<T>> Order compare(@NotNull java.lang.Iterable<? extends T> seq1, @NotNull java.lang.Iterable<? extends T> seq2, @NotNull Order longerOrder)
T
- common (super) element type of both sequencesseq1
- first sequenceseq2
- second sequencelongerOrder
- order which is returned when both sequences contain the same elements,
but the second sequence is longer. If in this case the first sequence is
longer, the Order.inverse()
of longerOrder
will be returned.Order
enum value describing the order of both sequences@NotNull public static <T> Order compare(@NotNull java.lang.Iterable<? extends T> seq1, @NotNull java.lang.Iterable<? extends T> seq2, @NotNull Ordering<? super T> ordering)
T
- common (super) element type of both sequencesseq1
- first sequenceseq2
- second sequenceordering
- ordering relationOrder
enum value describing the order of both sequences@NotNull public static <T> Order compare(@NotNull java.lang.Iterable<? extends T> seq1, @NotNull java.lang.Iterable<? extends T> seq2, @NotNull Order longerOrder, @NotNull Ordering<? super T> ordering)
T
- common (super) element type of both sequencesseq1
- first sequenceseq2
- second sequencelongerOrder
- order which is returned when both sequences contain the same elements,
but the second sequence is longer. If in this case the first sequence is
longer, the Order.inverse()
of longerOrder
will be returned.ordering
- ordering relationOrder
enum value describing the order of both sequences@NotNull public static <T> Order compare(@NotNull java.util.Iterator<? extends T> it1, @NotNull java.util.Iterator<? extends T> it2, @NotNull Ordering<? super T> ordering)
T
- common (super) element type of both sequencesit1
- iterator of the first sequence (changed)it2
- iterator of the second sequence (changed)ordering
- ordering relationOrder
enum value describing the order of both sequences@NotNull public static <T extends java.lang.Comparable<T>> Order compare(@NotNull java.util.Iterator<? extends T> it1, @NotNull java.util.Iterator<? extends T> it2)
T
- common (super) element type of both sequencesit1
- iterator of the first sequence (changed)it2
- iterator of the second sequence (changed)Order
enum value describing the order of both sequences@NotNull public static <T extends java.lang.Comparable<T>> Order compare(@NotNull java.util.Iterator<? extends T> it1, @NotNull java.util.Iterator<? extends T> it2, @NotNull Order longerOrder)
T
- common (super) element type of both sequencesit1
- iterator of the first sequence (changed)it2
- iterator of the second sequence (changed)longerOrder
- order which is returned when both sequences contain the same elements,
but the second sequence is longer. If in this case the first sequence is
longer, the Order.inverse()
of longerOrder
will be returned.Order
enum value describing the order of both sequences@NotNull public static <T> Order compare(@NotNull java.util.Iterator<? extends T> it1, @NotNull java.util.Iterator<? extends T> it2, @NotNull Order longerOrder, @NotNull Ordering<? super T> ordering)
T
- common (super) element type of both sequencesit1
- iterator of the first sequence (changed)it2
- iterator of the second sequence (changed)longerOrder
- order which is returned when both sequences contain the same elements,
but the second sequence is longer. If in this case the first sequence is
longer, the Order.inverse()
of longerOrder
will be returned.ordering
- ordering relationOrder
enum value describing the order of both sequences