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

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 count(c@:set[`T], x:T):int;
method collection_name(@:set[`T]):string;
signature copy(set[`T]):set[T];
signature copy_mutable(set[`T]):m_set[T];
abstract object i_set[T <= comparable[T]] isa set[T],
                                              i_unordered_collection[T];
method collection_name(@:i_set[`T]):string;
Sets refine the unordered collection set-like operations to return sets, not just plain unordered collections.

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 copy_mutable(s@:empty_set[`T]):m_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@:`T <= m_set[`Telm]):`T2 where signature copy_mutable(T):T2;
  method copy_mutable(c@:`T <= m_set[`Telm]):`T2
                                        where signature copy_empty(T):T2;
Mutable sets can be added to.


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

Cecil/Vortex Project