Next: , Up: bytevectors 8 compar   [Index]


27.2.6.1 Lexicographic comparison

Function: %bytevector-s8-compare bv1 beg1 past1 bv2 beg2 past2 proc< proc= proc>
Function: %bytevector-u8-compare bv1 beg1 past1 bv2 beg2 past2 proc< proc= proc>
Function: %bytevector-s8-compare-ci bv1 beg1 past1 bv2 beg2 past2 proc< proc= proc>
Function: %bytevector-u8-compare-ci bv1 beg1 past1 bv2 beg2 past2 proc< proc= proc>
Macro: bytevector-s8-compare B1 B2 proc< proc= proc>
Macro: bytevector-u8-compare B1 B2 proc< proc= proc>
Macro: bytevector-s8-compare-ci B1 B2 proc< proc= proc>
Macro: bytevector-u8-compare-ci B1 B2 proc< proc= proc>

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
Function: %bytevector-s8= bv1 beg1 past1 bv2 beg2 past2
Function: %bytevector-u8= bv1 beg1 past1 bv2 beg2 past2
Function: %bytevector-s8-ci= bv1 beg1 past1 bv2 beg2 past2
Function: %bytevector-u8-ci= bv1 beg1 past1 bv2 beg2 past2
Macro: bytevector-s8= B1 B2
Macro: bytevector-u8= B1 B2
Macro: bytevector-s8-ci= B1 B2
Macro: bytevector-u8-ci= B1 B2

Compare two subvectors: return true if they are equal, #f otherwise.

Function: %bytevector-s8<> bv1 beg1 past1 bv2 beg2 past2
Function: %bytevector-u8<> bv1 beg1 past1 bv2 beg2 past2
Function: %bytevector-s8-ci<> bv1 beg1 past1 bv2 beg2 past2
Function: %bytevector-u8-ci<> bv1 beg1 past1 bv2 beg2 past2
Macro: bytevector-s8<> B1 B1
Macro: bytevector-u8<> B1 B1
Macro: bytevector-s8-ci<> B1 B2
Macro: bytevector-u8-ci<> B1 B2

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.

Function: %bytevector-s8< bv1 beg1 past1 bv2 beg2 past2
Function: %bytevector-u8< bv1 beg1 past1 bv2 beg2 past2
Function: %bytevector-s8-ci< bv1 beg1 past1 bv2 beg2 past2
Function: %bytevector-u8-ci< bv1 beg1 past1 bv2 beg2 past2
Macro: bytevector-s8< B1 B2
Macro: bytevector-u8< B1 B2
Macro: bytevector-s8-ci< B1 B2
Macro: bytevector-u8-ci< B1 B2

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.

Function: %bytevector-s8<= bv1 beg1 past1 bv2 beg2 past2
Function: %bytevector-u8<= bv1 beg1 past1 bv2 beg2 past2
Function: %bytevector-s8-ci<= bv1 beg1 past1 bv2 beg2 past2
Function: %bytevector-u8-ci<= bv1 beg1 past1 bv2 beg2 past2
Macro: bytevector-s8<= B1 B2
Macro: bytevector-u8<= B1 B2
Macro: bytevector-s8-ci<= B1 B2
Macro: bytevector-u8-ci<= B1 B2

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.

Function: %bytevector-s8> bv1 beg1 past1 bv2 beg2 past2
Function: %bytevector-u8> bv1 beg1 past1 bv2 beg2 past2
Function: %bytevector-s8-ci> bv1 beg1 past1 bv2 beg2 past2
Function: %bytevector-u8-ci> bv1 beg1 past1 bv2 beg2 past2
Macro: bytevector-s8> B1 B2
Macro: bytevector-u8> B1 B2
Macro: bytevector-s8-ci> B1 B2
Macro: bytevector-u8-ci> B1 B2

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.

Function: %bytevector-s8>= bv1 beg1 past1 bv2 beg2 past2
Function: %bytevector-u8>= bv1 beg1 past1 bv2 beg2 past2
Function: %bytevector-s8-ci>= bv1 beg1 past1 bv2 beg2 past2
Function: %bytevector-u8-ci>= bv1 beg1 past1 bv2 beg2 past2
Macro: bytevector-s8>= B1 B2
Macro: bytevector-u8>= B1 B2
Macro: bytevector-s8-ci>= B1 B2
Macro: bytevector-u8-ci>= B1 B2

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: , Up: bytevectors 8 compar   [Index]