Container
A container is a collection of objects. Container is a template that
must be instantiated with the type of objects contained. Subclasses
extend container to maintain order and index elements. An Iterator for a container steps through the
container an element at a time.
Subclasses:
Member functions:
- add: Conainer . T -> void
Adds the object.
- get_one : Container -> T
Gets an object.
- is_member : Container . T -> bool
Returns whether or not the
object is in the container.
- new_iterator : Container -> Iterator
Allocates and
returns a new iterator for the container. The receiver is
responsible for deallocation.
- remove : Container . T -> void
Removes the object.
- size : Container -> int
Returns the size of the container.
IMPORTANT!!! Note that in GNU 2.7.2, template unification
doesn't realize that a secondary operation (e.g. filter) defined on a
container also works on a subclass; you must explicitly typecast to
Container in passing arguments to such operations.
Secondary operations:
- construct: Container . int n . T (n of them) -> void
Adds the n elements to the container.
- copy: Container1 . Container2 -> void
Adds the elements of container1 to container2.
- difference_container: Container . Container . Container
-> void
Stores in the third container objects belonging to
the first container but not the second.
- filter: Container1 . (T->bool) . Container2 -> void
Performs the operation for each member of the first container, adding
the "good" members to the second container.
- for_each: Container . (T->void) -> void
Performs the
operation for each member of the container.
- intersection_container: Container . Container . Container
-> void
Stores in the third container objects belonging to both
of the first two containers.
- min_max: Container . (T.T->bool) . T* . T* -> void
Finds the minimum and maximum of the container with respect to the
provided less than predicate.
- reduce: Container . R . (R.T->R) -> R
Starting the with R object, "adds in" each member of the container
with the given function.
- remove_all Container . bool=false -> void
Removes all the elements from the container, deleting them if the flag
is set true.
- stats: Container . (T->double) . double* . double* -> void
Returns the average and standard deviation of the collection with
respect to the feature.
- transform: Container1 . (T1->T2) . Container2 -> void
Performs the operation for each member of the first container, adding
the associated object to the second container.
- union_container: Container . Container . Container
-> void
Stores in the third container objects belonging to either
of the first two containers.