extend collector[`T] isa ordered_collection[T];
extend type collector[T] subtypes collector[T1];
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:&(int):void):void;
method write(f@:unix_file, c@:collector[indexed[char]],
if_error:&(int):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@sequence[`S]:`T <= sequence[`S],
s2@sequence[`S]:`T <= sequence[`S]):collector[T];
method &&(s1@sequence[`S]:`T <= sequence[`S], c@:collector[`T]):collector[T];
method &&(c@:collector[`T], s2@sequence[`S]:`T <= sequence[`S]):collector[T];
method &&(c1@:collector[`T], c2@:collector[`T]):collector[T];
method ||(c1@:collector[`T], c2@:collector[`T]):collector[T];
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: