jal.bytes
Class Inspection

A class that encapsulates non-mutating sequence algorithms on one
and two arrays. All methods are static and all variables are
static and final, so this class has no constructors.

Most methods operate on a range of elements. A range is described
by the index of its first element and an index that is
one past its last element. So, for example,
[n, n+1) is a range that contains one element,
[n, n) is a range that contains zero elements,
and [n, n-1) is not a valid range.

search

Searches, within one range, for a sequence of elements equal
to the elements in a second range.
Note: the two
ranges are permitted to be in the same array and are permitted to
overlap.
Note: the worst-case performance of this algorithm is quadratic.

Parameters:

array1 - Array containing the first range.

array2 - Array containing the first range.

first1 - Beginning of the first range.

last1 - One past the end of the first range.

first2 - Beginning of the second range.

last2 - One past the end of the second range.

Returns:

The first index in the range
[first1, last1-len) such that
for every non-negative i<len
(where len = last2-first2), the
condition
array1[first1+n] == array2[first1+n]
is satisfied, or last1 if no such
index exists.

search

Searches, within one range, for a sequence of elements that match
the elements in a second range. Matching is defined as satisfying
a BinaryPredicate passed as an argument.
Note: the two
ranges are permitted to be in the same array and are permitted to
overlap.
Note: the worst-case performance of this algorithm is quadratic.

Parameters:

array1 - Array containing the first range.

array2 - Array containing the first range.

first1 - Beginning of the first range.

last1 - One past the end of the first range.

first2 - Beginning of the second range.

last2 - One past the end of the second range.

p - Condition to be tested pairwise.

Returns:

The first index in the range
[first1, last1-len) such that
for every non-negative i<len
(where len = last2-first2), the
condition
p.apply(array1[first1+n],array2[first1+n])
is satisfied, or last1 if no such
index exists.