next up previous contents index
Next: Bags Up: Collections Previous: Basic collections

Unordered collections

In unordered.cecil:


abstract object unordered_collection[T] isa collection[T]; 
extend type unordered_collection[`T] subtypes unordered_collection[`S >= T]; 
method count(c@:unordered_collection[`T <= comparable[T]], x:T):int; 
An unordered_collection is a group of elements in no particular order. It supports collection operations such as length, is_empty, do, pick_any, includes, find, and copy.


extend unordered_collection[`T <= comparable[T]] 
isa comparable[unordered_collection[T]];
method =(c1@:unordered_collection[`T <= comparable[T]], 
c2@:unordered_collection[T]):bool;
extend unordered_collection[`T <= hashable[T]] 
isa hashable[unordered_collection[T]];
method hash(c@:unordered_collection[`T <= hashable[T]], range:int):int; 
If the elements of the collection are comparable, then so is the collection. Two such collections are equal ( =) if they have the same elements (with the same number of occurrences), independent of order. (By contrast, two ordered collections are equal only if they contain the same elements in the same order.) If the elements of the collection are hashable, then so is the collection.

Two refinements of unordered_collection indicate whether the collection is known to be immutable (i_unordered_collection) or mutable (m_unordered_collection).


abstract object i_unordered_collection[T] isa unordered_collection[T]; 
extend type i_unordered_collection[`T] 
subtypes i_unordered_collection[`S >= T];
method copy(c@:i_unordered_collection[`T]):i_unordered_collection[T]; 
method copy_empty(c@:i_unordered_collection[`T] 
):i_unordered_collection[T];
An immutable unordered collection of some type T is a subtype of any immutable unordered collection of a supertype of T. In contrast, a mutable unordered collection of a type T has no subtyping relation to a mutable unordered collection of a different type. Both kinds are subtypes or a generic unordered collection of T or transitively any supertype of T.


abstract object m_unordered_collection[T] 
isa unordered_collection[T], extensible_collection[T];
method copy(c@:m_unordered_collection[`T]):m_unordered_collection[T]; 
signature copy_empty(m_unordered_collection[`T]):m_unordered_collection[T]; 
Mutable collections provide remove, add, and other operations of extensible_collection. Method copy_empty always returns an empty mutable collection with a type like that of its argument.



 
next up previous contents index
Next: Bags Up: Collections Previous: Basic collections

The Cecil project