class STR < $IS_LT{STR},$HASH,$STR,$ELT{CHAR},$FMT |
---|
**** | Strings. Strings are represented as arrays of characters. Every character is significant.
_ References: Gonnet and Baeza-Yates, "Handbook of Algorithms and Data Structures", Addison Wesley, 1991. Make modification routines private. |
$FMT | $ELT{_} | $ELT | $STR | $HASH | $IS_EQ | $IS_LT{_} | AREF{_} |
end; |
---|
acopyn(s:FSTR,n:INT) |
---|
**** | copy "n" chars from "s" into "self". Built-in. |
**** | 's' was just a temporary |
r::=new(selfsize+ssize); |
---|
r.acopy(p1,s1); |
---|
r.acopy(p2,s2); |
---|
r.acopy(p3,s3); |
---|
r.acopy(p4,s4); |
---|
when '\"' then buf:=buf+'\"' |
---|
**** | A copy of self with each character in upper case. Self may be void. |
**** | The index of the first character of self which differs from `s'. -1 if self is a prefix of `s'. Either may be void. |
if void(self) then return -1 end; |
---|
**** | Another name for `size'. |
r::=new(i); r.acopy(i-asize,self); |
---|
end; |
---|
**** | The index of the first appearance of `c' at location `st' or greater in self or -1 if absent. Self may be void. |
if beg=0 then return void end; |
---|
**** | A string whose characters are the reverse of those in self. Self may be void. |
create(c:CHAR):SAME |
---|
**** | String containing the single character 'c'. |
create:SAME |
---|
**** | An empty string. (Occasionally useful in constructs like `#STR + foo'). |
end; |
---|
create_from_file(nm:STR):SAME |
---|
**** | Open the file named `nm' in the current directory, create a string containing its contents and then close the file. Return void if there is no such file. |
end; |
---|
if void(self) then return 0 else return asize end |
---|
return r; |
---|
acopyn(s:STR,n:INT) |
---|
**** | copy "n" chars from "s" into "self". Built-in. |
r::=new(sz); |
---|
**** | contained in `s' or -1 if none. Self or `s' may be void. |
r::=new(asize); |
---|
if qt then return void |
---|
**** | Must close internal quotes. |
**** | by "memcmp" in MACROS. |
else return false end |
---|
else |
---|
if c.is_gt(sc) then return false |
---|
**** | True if `s' is lexicographically before self or equal to it. Either may be void. |
else |
---|
**** | True if `s' is lexicographically before self. Either may be void. |
r.aset!(c) end; |
---|
end; |
---|
**** | True if each alphabetic character of self is lower case. Self may be void. |
if ns=0 then return void end; |
---|
end; |
---|
**** | Specialized versions of plus |
**** | the following ones could be optimized if one gets excited about it |
if void(sarg) then return self end; |
---|
**** | r::=#FSTR(size);
______loop_r:=r.push(elt!);_end; ______return_r; ______end; |
end; |
---|
end; |
---|
substring(beg,num:INT):SAME |
---|
**** | The substring with `num' charcters whose first character has index `beg'. Self may be void if beg=0 and num=0. |
r::=0; loop if s.contains(elt!) then r:=r+1 end end; |
---|
if void(self) then return -1 end; |
---|
r.aset!(c) |
---|
end; |
---|
if ~s.contains(c) then r.aset!(c) end end; |
---|
end; |
---|
return false |
---|
loop if s.contains(elt!) then return true end end; |
---|
loop r.acopy(0.step!(i,asize),self) end; |
---|
return r |
---|
return -1 |
---|
end; |
---|
r.acopy(p5,s5); |
---|
**** | The first `i' characters of self. Self may be void if i=0. |
**** | Self may be void. |
**** | True if each alphabetic character of self is upper case. Self may be void. |
if void(s) then return 0 end; |
---|
loop until!(i = sz); yield [i]; i := i + 1; end; |
---|
loop until!(i = sz); yield [i]; i := i + 1; end; |
---|
**** | The character at index `i' of self. |
loop until!(i = sz); yield [i]; i := i + 1; end; |
---|
i:=i+1; |
---|
shared buf:FSTR; |
---|
**** | Character buffer. |
shared buf:FSTR; |
---|
**** | Character buffer. |
is_empty:BOOL |
---|
**** | True if self has no characters. Self may be void. |