Next: Lists
Up: Indexed collections: vector, array,
Previous: Implementations
Index
In string.diesel:
The string type is an abstract class representing an indexed
sequence of characters. Methods operating on generic strings that
both take and return strings, in most cases produce a new string as
a result.
module String;
abstract class string isa indexed_exactly[char];
In addition to all the operations available on other indexed
collections, characters can be concatenated onto
the front or back of a string using the || infix
operator. (The || operator can also concatenate two strings. This
behavior is inherited from sequences.)
The pad functions add either blanks or a specified padding
character to either the front or the back of the string to make it
be of at least the specified length.
fun pad(s:string, len:int):string; - pads on the right
fun pad_right(s:string, len:int):string;
fun pad_right(s:string, len:int, padding:char):string;
fun pad_left(s:string, len:int):string;
fun pad_left(s:string, len:int, padding:char):string;
A string_factory
is the abstract superclass of factories for
strings. It introduces a number of char-specific creation
operations, parallel to the ones that are parameterized by the
kind of element to create.
abstract class string_factory isa indexed_factory;
fun create_char_empty(:string_factory):string;
fun create_char_filled(:string_factory,
size:int, filler:char):string;
fun create_char_init(:string_factory,
size:int, cl:&(int):char):string;
fun create_char_mapped(:string_factory,
c:collection[`T1], cl:&(T1):char):string;
fun create_char_mapped_associations(:string_factory,
c:table[`K,`T1], cl:&(K,T1):char
):string;
fun create_char_copy(f:`F <= string_factory, c:collection[char]):`S
where create_char_mapped(:F,:collection[char],:&(char):char):S;
As usual, there are immutable and mutable varieties of strings.
abstract class i_string isa string, i_indexed_exactly[char];
abstract class i_string_factory isa string_factory, i_indexed_factory;
abstract class m_string isa string, m_indexed[char];
fun write_into_string_at_pos(s1:string, s2:m_string, pos:int):void;
abstract class m_string_factory isa string_factory, m_indexed_factory;
fun create_char_sized(:m_string_factory, size:int):m_string;
The vstring class and its two concrete subclasses, i_vstring
and
m_vstring
, provide a primitive fixed-length packed string
implementation. Diesel string literals (e.g., "hello") are instances
of i_vstring
. Various constructors for vstrings are provided,
analogously to strings and arrays.
abstract class vstring isa string;
fun as_vstring(c:collection[char]):vstring;
A vstring_factory
is the abstract superclass of factories for
vstrings.
abstract class vstring_factory isa string_factory;
abstract class i_vstring isa i_string, vstring;
fun new_i_vstring(size:int):i_vstring;
fun new_i_vstring(size:int, filler_oop:char):i_vstring;
fun new_i_vstring_init(size:int, cl:&(int):char):i_vstring;
fun new_i_vstring_init_from(c:collection[`T], cl:&(T):char):i_vstring;
fun new_i_vstring_init_from_associations(c:table[`K,`T],
cl:&(K,T):char):i_vstring;
fun as_i_vstring(c:collection[char]):i_vstring;
An i_vstring_factory
is the concrete factory object for
i_vstrings.
object i_vstring_factory isa vstring_factory, i_string_factory;
abstract class m_vstring isa m_string, vstring;
fun new_m_vstring(size:int):m_vstring;
fun new_m_vstring_no_init(size:int):m_vstring;
fun new_m_vstring(size:int, filler_oop:char):m_vstring;
fun new_m_vstring_init(size:int, cl:&(int):char):m_vstring;
fun new_m_vstring_init_from(c:collection[`T], cl:&(T):char):m_vstring;
fun new_m_vstring_init_from_associations(c:table[`K,`T],
cl:&(K,T):char):m_vstring;
fun as_m_vstring(c:collection[char]):m_vstring;
An m_vstring_factory
is the concrete factory object for
m_vstrings.
object m_vstring_factory isa vstring_factory, m_string_factory;
Next: Lists
Up: Indexed collections: vector, array,
Previous: Implementations
Index
Cecil/Vortex Project