class FSTR < $IS_LT{FSTR}, $HASH, $STR
****
Buffers for efficiently constructing strings by repeated concatenation using amortized doubling. Some useful features are: size:INT The current string size. create(n:INT):SAME A buffer of initial size `n'. copy:SAME A copy of self. aget(ind:INT):CHAR The character `ind'. aset(ind:INT, c:CHAR) Set character `ind' to `c'. is_eq(l:SAME):BOOL True if self equals l as strings. is_empty:BOOL True if self is the empty string. clear Make self represent the empty string. elt!:CHAR The characters in self. elt!(beg:INT):CHAR Characters starting at `beg'. elt!(beg,num:INT):CHAR `num' chars beginning at `beg'. elt!(beg,num,step:INT):CHAR `num' chars beginning at `beg',
____stepping_by_`step'.
ind!:INT The indices of the buffer. contains(c:CHAR):BOOL True if self contains `c'. to_reverse Reverse the order of the characters.


Flattened version is here

Ancestors
$STR $HASH $IS_EQ $IS_LT{_}
FLIST{_} $ARR{_} $RO_ARR{_} $CONTAINER{_}
$ELT{_} $ELT AREF{_}



Public


Features
acopy(f:FSTR)
acopy(beg:INT,src:FSTR)
acopy(beg:INT,src:STR)
acopy(s:STR)
acopyn(s:FSTR,n:INT)
acopyn(s:STR,n:INT)
append_file(nm:STR):SAME
**** Open the file named `nm' in the current directory, append its contents to self, close the file, and return the new buffer. Do nothing if the file cannot be opened.
append_file_range(nm:STR,st,sz:INT):SAME
**** Open the file named `nm' in the current directory, append at most `sz' characters starting at `st' to self (only as many as are there), close the file, and return the new buffer. Do nothing if the file cannot be opened.
clear
**** Set self to the empty string. Retain the array. Self may be void.
create(sz:INT):SAME
**** A new buffer of size `sz'.
create(s:STR):SAME
**** added by MBK to make STR::fstr:FSTR faster
create:SAME
**** A new buffer.
hash0:INT
**** An inexpensive to compute hash function of self. Gives an INT with rightmost 24 bits. Also gives lousy hash functions. Void gives 0.
hash:INT
**** Keep It Simple, Stupid.
head(i:INT):SAME
**** The first `i' characters of self. Self may be void if i=0.
is_eq(s:SAME):BOOL
**** True if `s' equals self. Either may be void. MBK.
is_eq(s:STR):BOOL
**** so you can say `` if FSTR = "blabitty blah blah blah" ''
is_lower:BOOL
**** True if each alphabetic character of self is lower case. Self may be void.
is_lt(s:SAME):BOOL
**** True if self is lexicographically before `s'. Void is before everything else.
is_neq(s:SAME):BOOL
**** True if `s' is not equal to self. Either may be void.
is_neq(s:STR):BOOL
**** True if `s' is not equal to self. Either may be void.
is_upper:BOOL
**** True if each alphabetic character of self is upper case. Self may be void.
length:INT
**** The number of characters in self. Another name for `size'.
plus(b:BOOL):SAME
**** Append `b' to self and return it.
plus(c:CHAR):SAME
**** Append `c' to self and return it.
plus(f:FLT):SAME
**** Append `f' to self and return it.
plus(s:SAME):SAME
**** Append `s' to self and return it.post result.str = initial(self.str) + initial(s.str)
plus(i:INT):SAME
**** Append `i' to self and return it.
plus(s:STR):SAME
**** Append the string `s' to self and return it. modified by MBK et al to make it go fast. Called by compiler frequently.
push(c:CHAR):SAME
**** Add a new character to the end of self and return it. If self is void, create a new list. Usage: `l:=l.push(e)'. This routine needs to go fast too, which is the reason behind the "l" temporary. Modified by MBK.
str:STR
**** A string version of self.
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.
tail(i:INT):SAME
**** The last `i' characters of self. Self may be void if i=0.
thumbprint:STR
**** Compute a representation to use in place of the whole text. The probability that two thumbprints are the same for two different FSTRs should be vanishingly small. This is a little more paranoid than the hash function.

Iters
separate!(s:SAME):FSTR
**** On the first iteration just outputs `s', on successive iterations it outputs self followed by `s'. Useful for forming lists, Eg: loop #OUT + ", ".fstr.separate!(a.elt!) end; incorporated Erik's fixes


Private

is_eq_helper(s:SAME,i:INT):BOOL
is_eq_helper(s:STR,i:INT):BOOL