This interface defines operations on strings of 16-bit WIDECHAR
s.
They are represented by address of the first character of
the string and the string's length in characters.
INTERFACEString16 ; PROCEDURE Equal (a, b: ADDRESS; len: CARDINAL): BOOLEAN;
ReturnTRUE
if the strings oflen
characters starting ata
andb
have the same (case-sensitive) contents.
PRE: a MOD ADRSIZE(WIDECHAR) = 0 AND b MOD ADRSIZE(WIDECHAR) = 0
PROCEDURE Compare (a: ADDRESS; len_a: CARDINAL; b: ADDRESS; len_b: CARDINAL): [-1..1];
Return-1
if stringa
occurs before stringb
,0
if the strings are equal, and+1
ifa
occurs afterb
in lexicographic order.
PRE: a MOD ADRSIZE(WIDECHAR) = 0 AND b MOD ADRSIZE(WIDECHAR) = 0
PROCEDURE Hash (a: ADDRESS; len: CARDINAL; initial: INTEGER): INTEGER;
Return a hash function of the contents of stringa
starting with the valueinitial
.
PRE: a MOD ADRSIZE(WIDECHAR) = 0
PROCEDURE FindChar (a: ADDRESS; len: CARDINAL; c: WIDECHAR): INTEGER;
Ifc = a[i]
for somei
in[0~..~len-1]
, return the smallest suchi
; otherwise, return-1
.
PRE: a MOD ADRSIZE(WIDECHAR) = 0
PROCEDURE FindCharR (a: ADDRESS; len: CARDINAL; c: WIDECHAR): INTEGER;
Ifc = a[i]
for somei
in[0~..~len-1]
, return the largest suchi
; otherwise, return-1
.
PRE: a MOD ADRSIZE(WIDECHAR) = 0
PROCEDURE HasWideChars (a: ADDRESS; len: CARDINAL): BOOLEAN;
Return ORD(a[i]) > LAST (CHAR), for somei
in[0~..~len-1]
.
PRE: a MOD ADRSIZE(WIDECHAR) = 0
PROCEDURE ArrayStart (READONLY a: ARRAY OF WIDECHAR): ADDRESS;
Returns the address of the first character ofa
if it is non-empty, otherwise returnsNIL
. WARNING: the returned address is only valid as long asa
does not move. To prevent heap allocated arrays from moving, keep the returned address on the stack.
END String16.