Introduction
Cat::FiniteCollection
represents the category of finite
collections, i.e., the category of ``universal'' bags.
Generating
the category
Cat::FiniteCollection()
Categories
Cat::BaseCategory
Details
- A finite collection is a data structure where each element
represents a finite bag of ``things'' of any type.
- The elements are numbered 1,...,
nops(c)
, where
nops(c)
is the number of elements in the bag.
Method _index: returns element given its index
_index(dom x, Type::PosInt i)
-
- Must return the
i
-th element of x
.
Method map: maps function on elements
map(dom x, function f
<, a...>)
-
- Must replace each element
e
of x
by
f(e,a...)
and return the result.
Method nops: returns number of elements
nops(dom x)
-
- Must return the number of elements of
x
.
Method op: returns certain elements
op(dom x)
-
- Must return a sequence of all elements of
x
.
op(dom x, Type::PosInt i)
-
- Must return the
i
-th element of x
or
FAIL
if an element with the given index does not
exist.
- Operand ranges or pathes need not be handled by this method because
they are handled directly by
op
.
Method set_index: changes element with given index
set_index(dom x, Type::PosInt i, v)
-
- Must replace the
i
-th element of x
by
v
.
- Overloads the function
_assign
. The result is assigned to
x
.
Method subs: substitute in elements
subs(dom x, e = f)
-
- In each element of
x
the expression e
must be substituted by f
.
Method subsop: substitute operands
subsop(dom x, Type::PosInt i = v)
-
- Must replace the
i
-th element of x
by
v
.
Method mapCanFail: maps function on elements
mapCanFail(dom x, function f <, a...>)
-
- Replaces each element
e
of x
by
f(e,a...)
. If one of the results of the calls is FAIL
, then FAIL
is returned.
Method testEach: test each element with a predicate
testEach(dom x, function f <, a...>)
-
- For each element
e
of x
the call
f(e,a...)
is evaluated. The calls must return boolean
values. If one of the results is not TRUE
then FALSE
is returned, TRUE
otherwise.
Method testOne: tests if element exists fulfilling a predicate
testOne(dom x, function f <, a...>)
-
- For each element
e
of x
the call
f(e,a...)
is evaluated. The calls must return boolean
values. If one of the results is TRUE
then TRUE
is returned, FALSE
otherwise.
Changes
- Has been renamed. Used to be
Cat::FiniteCollectionCat
.
Do you have
questions or comments?
Copyright © SciFace Software GmbH & Co. KG
2000