Next: Histograms
Up: Advanced collection
Previous: Keyed sets
Index
In collector.cecil:
template object collector[T <= sequence[S]]
isa ordered_collection[T]
subtypes collector[`T1 >= T];
method flat_vector(c@:collector[`T <= sequence[`S]]):vector[S];
method add_first(c@:collector[`T], x:`T):void;
method add_last(c@:collector[`T], x:T):void;
method new_collector[T <= sequence[`S]]():collector[T];
method new_collector[T <= sequence[`S]](size:int):collector[T];
method copy(c@:collector[`T]):collector[T];
method collection_name(@:collector[`T]):string;
signature flat_string(string|collector[string]):string;
method flat_string(c@:collector[string]):string;
method flat_string(c@:string):string;
signature write(unix_file, indexed[char] | collector[indexed[char]],
if_error:&(string):void):void;
method write(f@:unix_file, c@:collector[indexed[char]],
if_error:&(string):void):void;
signature write(unix_file, indexed[char] | collector[indexed[char]]):void;
method write(f@:unix_file, c@:collector[indexed[char]]):void;
signature &&((`T <= sequence[`S]) | collector[`T],
(`T <= sequence[`S]) | collector[`T]):collector[T];
method &&(s1@:`T <= sequence[`S],
s2@:`T <= sequence[`S]):collector[T];
method &&(s1@:`T <= sequence[`S], c@:collector[`T]):collector[T];
method &&(c@:collector[`T], s2@:`T <= sequence[`S]):collector[T];
method &&(c1@:collector[`T], c2@:collector[`T]):collector[T];
method ||(c1@:collector[`T], c2@:collector[`T]):collector[T];
Sequences support the || concatenation operator. However, for long series
of concatenations, using || many times can be inefficient and imply lots
of copying. The collector extensible sequence data structure supports
accumulating sequences for latter concatenation in one fell swoop.
Collectors can be created (optionally with a non-binding guess as to
how many things will be collected together) using new_collector. The
infix && operation is the more common way to construct
collectors. Collectors are flattened into a vector form using
flat_vector
, and collectors of character sequences can be flattened
into a simple string using flat_string
. To illustrate the use of
collectors versus concatenation:
("hi" && "there" && "bob").flat_string = "hi" || "there" || "bob"
Next: Histograms
Up: Advanced collection
Previous: Keyed sets
Index
Cecil/Vortex Project