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.


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



Public


Readable Attributes
attr loc:INT; .. Included as loc
**** The index to insert the next element.

Writable Attributes
attr loc:INT; .. Included as loc
**** The index to insert the next element.

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)
aget(ind:INT):T .. Included as aget
**** The element of self with index `ind'. Self may not be void.
append(l:SAME):SAME .. Included as append
**** Append `l' to the end of self and return the result. Self may be void. `l' mustn't equal self unless void. Modified(ben) - hopefully much more efficient - no iters
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.
array:ARRAY{T} .. Included as array
**** An array containing the elements of self. Void if self is void.
as_array:ARRAY{T} .. Included as as_array
aset(ind:INT,val:T) .. Included as aset
**** Set the element of self with index `ind' to `val'. Self may not be void.
asize:INT .. Included as asize
**** The number of elements in self. Classes which inherit this may replace this by a constant to get constant sized objects (and the compiler may optimize certain operations in this case). Built-in.
clear
**** Set self to the empty string. Retain the array. Self may be void.
concat(l:SAME):SAME .. Included as concat
**** Append 'l' destructively. 'l' mustn't equal self unless void. Modified (ben) - hopefully more efficient - no iters, single alloc
contains(e: T): BOOL .. Included as contains
copy:SAME .. Included as copy
**** A copy of self.
count(e:T):INT .. Included as count
**** Return the number of occurences of 'e' in self
create(a: ARRAY{T}): SAME .. Included as create
**** Create a new FLIST from the elements in the array "a" Useful for using the array shorthand for specifying the elements
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.
create_empty_sized(n: INT): SAME .. Included as create_empty_sized
**** Create an flist with n elements that are set to elt_nil
create_from(a: $ELT{T}): SAME .. Included as create_from
**** Create from any container
delete(ind:INT) .. Included as delete
**** Delete the element with index `ind' and move the last element in its place. Self may not be void.
delete(ind: INT): SAME .. Included as delete
delete_elt(e: T) .. Included as delete_elt
**** Delete first occurance of element e from the list. Consider using FSET.
delete_elt(e: T): SAME .. Included as delete_elt
delete_elt_ordered(e: T) .. Included as delete_elt_ordered
**** Similar to delete_ord, but for the element "e"
delete_elt_ordered(e: T): SAME .. Included as delete_elt_ordered
delete_ordered(ind: INT) .. Included as delete_ordered
**** Delete the element with index `ind' and move up all other elements (thus preseving order). More expensive than 'delete'. Self may not be void.
delete_ordered(ind: INT): SAME .. Included as delete_ordered
difference(l:SAME):SAME .. Included as difference
**** A new list containing the elements of self not in `l'. Doesn't modify self or `l'. Consider FSET{T} for better performance. Self may be void.
elt_eq(e1,e2:ETP):BOOL .. Included as elt_eq
elt_hash(e:$OB):INT .. Included as elt_hash
elt_lt(e1,e2:ETP):BOOL .. Included as elt_lt
elt_nil:ETP .. Included as elt_nil
equals(l: $CONTAINER{T}): BOOL .. Included as equals
**** Return true if the elemetns of "l" are the same as the elements of self
fill(e: T) .. Included as fill
has(e:T):BOOL .. Included as has
**** True if `e' is contained in self.
has_ind(i: INT): BOOL .. Included as has_ind
**** Return true if "i" is a valid index in this FLIST
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.
index_of(e:T):INT .. Included as index_of
**** The list index of `e'. -1 if the list is void or the element is not present (not fast). Consider using FSET{T}.
inds: ARRAY{INT} .. Included as inds
**** Return an array consisting of the indices of the FLIST
insert_after(ind:INT, val:T): SAME .. Included as insert_after
**** Insert the value "val" after the index "ind". push all later elements upwards.
insert_all_after(ind:INT, val:$CONTAINER{T}):SAME .. Included as insert_all_after
insert_all_before(ind:INT, val:$CONTAINER{T}) :SAME .. Included as insert_all_before
**** Insert all the values in "val" before the element in self at index "ind" in the order in which they are yielded by "val.elt!"
insert_before(ind:INT, val:T): SAME .. Included as insert_before
**** Insert val just before index "ind"
intersect(l:SAME):SAME .. Included as intersect
**** A new list containing the elements in both self and `l'. Doesn't modify self or `l'. Consider FSET{T} for better performance. Self may be void.
is_elt_nil(e:ETP):BOOL .. Included as is_elt_nil
is_empty:BOOL .. Included as is_empty
**** True if the list is empty or void.
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_eq(arg: $OB): BOOL .. Included as is_eq
**** Overloaded version of the is_eq routine that works with an argument of any type. If the type of the 'arg' is not the same as they type of 'self' then return false. Otherwise, deletegate to the 'real' is_eq(SAME):BOOL routine
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_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.
pop:T .. Included as pop
**** Return the top element and shrink the list. Void if the list is empty or void.
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.
push_if_new(e:T):SAME .. Included as push_if_new
**** Push `e' if it is not already present in the list. Self may be void. Usage is: `l:=l.push_if_new(e)'. Consider using FSET{T}.
reset .. Included as reset
**** Semantically identical to clear, but don't reset array values (space may not be freed). Useful for quickly emptying the list when you know it won't matter.
size:INT .. Included as size
**** The current size. Self may be void.
str:STR
**** A string version of self.
sublist(beg,num:INT):SAME .. Included as sublist
**** A new list with `num' entries copied from self starting at `beg'. Self may not be void.
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.
sym_difference(l:SAME):SAME .. Included as sym_difference
**** A new list containing the elements in self or `l' but not both. Doesn't modify self or `l'. Consider FSET{T} for better performance. Self may be void.
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.
to_reverse .. Included as to_reverse
**** Reverse the order of the elements in self. Self may be void.
top:T .. Included as top
**** The value of the top of the list. Void if the list is empty or void.
union(l:SAME):SAME .. Included as union
**** A new list containing the elements in self unioned with those in `l'. Doesn't modify self or `l'. Self may be void. Consider using FSET{T} for better performance.
valid_after_ind(i: INT): BOOL .. Included as valid_after_ind
valid_before_ind(i:INT): BOOL .. Included as valid_before_ind

Iters
elt!(once beg:INT):T .. Included as elt!
**** Yield the elements of self starting at `beg'. Don't insert elements while calling this. Modified (ben) - Looked at fast version - does not seem to be optimized out. Must ask Claudio about this
elt!(once beg,once num:INT):T .. Included as elt!
**** Yield `num' successive elements starting at index `beg'. Don't insert elements while calling this.
elt!(once beg,once num,once step:INT):T .. Included as elt!
**** Yield `num' elements starting at `beg' stepping by `step'.
elt!:T .. Included as elt!
**** Yield the elements of self in order. Self may be void. Don't insert elements while calling this. Modified (ben) - must ask Claudio
ind!:INT .. Included as ind!
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
set!(e: T) .. Included as set!


Private

aclear .. Included as aclear
**** Set each element of self to nil. Built-in.
acopy(beg,num:INT, src:SAME) .. Included as acopy
**** Copy `num' elements from `src' to self starting at index `beg' of self.
acopy(beg,num,srcbeg:INT, src:SAME) .. Included as acopy
**** Copy `num' elements from `src' to self starting at index `beg' of self and index `srcbeg' of `src'. Built-in.
aelt!(once beg:INT):T .. Included as aelt!
**** Yield each element of self starting at `beg'. Built-in.
aelt!(once beg,once num:INT):T .. Included as aelt!
**** Yield `num' successive elements of self starting at index `beg'. Built-in.
aelt!(once beg,once num,once step:INT):T .. Included as aelt!
**** Yield `num' elements of self starting at `beg' and stepping by `step' which must not be zero. Built-in.
aelt!:T .. Included as aelt!
**** Yield each element of self in order. Built-in.
aind!:INT .. Included as aind!
**** Yield the indices of self in order.
aget(ind:INT):T .. Included as aref_aget
**** The element of self with index `ind'. Built-in.
aset(ind:INT, val:T) .. Included as aref_aset
**** Set the element of self with index `ind' to `val'. Built-in.
array_ptr:C_PTR .. Included as array_ptr
aset!(val:T) .. Included as aset!
**** Set successive elements of self to the values `val'. Built-in.
aset!(once beg:INT,val:T) .. Included as aset!
**** Set successive elements of self starting at `beg' to the values `val'.
aset!(once beg,once num:INT,val:T) .. Included as aset!
**** Set `num' successive elements of self starting at `beg' to the values `val'.
aset!(once beg,once num,once step:INT, val:T) .. Included as aset!
**** Set `num' elements of self starting at `beg' stepping by `step' to the values `val'. `step' must not be zero.
expand_to_size(new_size: INT): SAME .. Included as expand_to_size
**** Expand space so that the result has space for "new_size" elements. Then set the location to new_size, indicating that it is filled After this is done, the resulting array will be of size = new_size and will have all the old elements of "self" copied over and the remaining elements (if any) void
is_eq_helper(s:SAME,i:INT):BOOL
is_eq_helper(s:STR,i:INT):BOOL
is_legal_aelts_arg( beg, num, step:INT) :BOOL .. Included as is_legal_aelts_arg
**** True if the arguments are legal values for `aelts'.
is_legal_iteration(beg,num,step:INT,container_size:INT): BOOL .. Included as is_legal_iteration
**** True if the arguments are legal for an iteration from index beg, with a step of "step" for "num" iterators in a container of size "container_size"
push_downward(from_ind: INT, by: INT) .. Included as push_downward
**** Push all the elements from index "from_ind" downward by "ind" spots. The last elements are pushed off the end

The Sather Home Page