Next: bytevectors 8 compar dict, Up: bytevectors 8 compar [Index]
Determine the mismatch index between the two subvectors: the largest index i such that for every 0 <= j < i, bv1[j] = bv2[j]; that is, i is the first position that does not match.
The mismatch index is always an index into bv1; in the case of equal bytevectorss, it is always past1; the functions observe the protocol in this redundant case for uniformity.
proc<, proc=, or proc> are applied to the mismatch index (not byte), depending upon whether the subvector of bv1 is less than, equal to, or greater than the subvector of bv2. The result of the application is returned.
If we just want to have the mismatch index as return value: we can use
values
as value for proc<, proc= and proc>.
Another interesting option is to use (lambda (mismatch-index) #f)
or (lambda (mismatch-index) #t)
.
Examples:
(define S string->utf8) (bytevector-u8-compare (S "abcd") (S "abcd") values values values) ⇒ 4 (bytevector-u8-compare (S "abcd") (S "abcd12") values values values) ⇒ 4
Compare two subvectors: return true if they are equal, #f
otherwise.
Compare two subvectors: return #f
if they are equal, true
otherwise.
The following predicates are the lexicographic extensions of the corresponding integer and character predicates. A bytevector bv1 is “lexicographically” less than bv2 if, after conversion to strings in ASCII encoding, bv1 would come first in a dictionary.
Compare two subvectors: return true if the first is lexicographically
less than the second, #f
otherwise. If bv2 is longer than
bv1 but the subvectors are equal up to the end of bv1:
return #t
.
Compare two subvectors: return true if the first is lexicographically
less than, or equal to, the second; #f
otherwise. If bv2
is longer than bv1 but the subvectors are equal up to the end of
bv1: return #t
.
Compare two subvectors: return true if the first is lexicographically
greater than the second, #f
otherwise. If bv1 is longer
than bv2 but the subvectors are equal up to the end of
bv2: return #t
.
Compare two subvectors: return true if the first is lexicographically
greater than, or equal to, the second; #f
otherwise. If bv1
is longer than bv2 but the subvectors are equal up to the end of
bv2: return #t
.
Next: bytevectors 8 compar dict, Up: bytevectors 8 compar [Index]