abstract object bag[T] isa unordered_collection[T];
extend type bag[`T] subtypes bag[`S >= T];
signature copy(bag[`T]):bag[T];
abstract object i_bag[T] isa bag[T], i_unordered_collection[T];
signature copy(i_bag[`T]):i_bag[T];
abstract object m_bag[T] isa bag[T], m_unordered_collection[T];
extend m_bag[`T <= comparable[T]] isa removable_collection[T];
signature copy(m_bag[`T]):m_bag[T];
Bags are a specialization of unordered collections that
explicitly allow duplicates.
template object list_bag[T] isa m_bag[T];
method collection_name(@:list_bag[`T]):string;
method length(m@:list_bag[`T]):int;
method is_empty(m@:list_bag[`T]):bool;
method do(m@:list_bag[`T], c:&(T):void):void;
method add(m@:list_bag[`T], x:T):void;
method remove(m@:list_bag[`T <= comparable[T]], x:T,
if_absent:&():void):void;
method remove_any(m@:list_bag[`T], if_empty:&():`S):T|S;
method remove_if(m@:list_bag[`T], pred:&(T):bool):int;
method remove_all(m@:list_bag[`T]):void;
method new_list_bag[T]():list_bag[T];
method copy_empty(c@:list_bag[`T]):list_bag[T];
method as_ordered_collection(c@:list_bag[`T]):m_list[T];
The