next up previous contents index
Next: Set implementations Up: Unordered collections Previous: Bags

Sets

In set.cecil:


abstract object set[T <= comparable[T]] isa unordered_collection[T]; 
extend type set[`T] subtypes set[`S >= T]; 
Sets are a specialization of unordered collections that explicitly disallow duplicates.


method union(m1@:set[`T], m2@:set[T]):m_set[T]; 
method intersection(m1@:set[`T], m2@:set[T]):m_set[T]; 
method difference(m1@:set[`T], m2@:set[T]):m_set[T]; 
method is_disjoint(m1@:set[`T], m2@:set[T]):bool; 
method is_subset(m1@:set[`T], m2@:set[T]):bool; 
method count(c@:set[`T], x:T):int; 
method collection_name(@:set[`T]):string; 
signature copy(set[`T]):set[T]; 
abstract object i_set[T <= comparable[T]] isa set[T], i_unordered_collection[T]; 
method collection_name(@:i_set[`T]):string; 
Sets support a collection of functional set operations which, given argument sets, return a new set.


concrete object empty_set[T <= comparable[T]] isa i_set[T]; 
method print_string(@:empty_set[`T]):string; 
method copy(s@:empty_set[`T]):empty_set[T]; 
method copy_empty(s@:empty_set[`T]):empty_set[T]; 
method do(s@:empty_set[`T], c:&(T):void):void; 
method do_allowing_updates(s@:empty_set[`T], c:&(T):void):void; 
signature do_allowing_updates(empty_set[`T]|m_set[`T], c:&(T):void):void; 
method length(@:empty_set[`T]):int; 
method is_empty(@:empty_set[`T]):bool; 
One standard implementation of an immutable set is the concrete object empty_set.


abstract object m_set[T <= comparable[T]] isa set[T], 
m_unordered_collection[T],
removable_collection[T];
method collection_name(@:m_set[`T]):string; 
method add(m@:m_set[`T], x:T):void; 
method check_if_missing_and_add(m@:m_set[`T], x:T):bool; 
signature add_functional(m_set[`T], x:T):m_set[T]; 
signature copy_empty(m_set[`T]):m_set[T]; 
method copy(c@:m_set[`T]):m_set[T]; 
Mutable sets can be added to.


next up previous contents index
Next: Set implementations Up: Unordered collections Previous: Bags

The Cecil project