bag
Section: OATH Reference Manual (3O)
Updated: 26 August 1991
Index
Return to Main Contents
NAME
bag (bagA, bagG) - a collection of objs
SYNOPSIS
#include <oath/bag.h>
DESCRIPTION
The bag is a collection of objs. Objs can be inserted into a bag; however
a bag may act as a "sieve" or "filter", holding only certain types of objs,
allowing the others to "fall through". For instance, a string is a bag
that holds only characters. If a non-character is inserted into a string,
it just falls through. Other "filtering" bags may be more complex,
transforming inserted objs into other objs.
A bag can be checked for emptiness, for a count of objs it contains, or
for containment of a particular obj. A simple function may also be applied
to each member of the bag. Note that a bag may or may not support an
ordering of its members, thus successive applications of a function to
its members may be applied in different orderings.
DERIVATION
bag : obj
bag is an abstract type.
STATIC OPERATIONS
- bagA bagA:: isa (objA)
-
bagA::isa(O) returns O if it is truly a bag; otherwise it returns Nil.
MEMBER OPERATIONS
- int bagA:: isEmpty ()
-
B.isEmpty() returns TRUE if B has no members (FALSE otherwise).
- int bagA:: count ()
-
B.count() returns the number of members in B.
- int bagA:: contains (objA)
-
B.contains(O) returns TRUE if O is a member of B (FALSE otherwise).
- int bagA:: containsEqual (objA)
-
B.containsEqual(O) returns TRUE if B contains an obj that isEqual(O).
- bagA bagA:: insert (objA)
-
B.insert(O) inserts obj O into bag B. Depending upon the type of B, O may
fall through or be transformed.
- bagA bagA:: operator << (objA)
-
B << O is the same as B.insert(O).
- bagA bagA:: append (bagA)
-
B1.append(B2) inserts each obj in B2 into B1.
- bagA bagA:: operator << (bagA)
-
B1 << B2 is the same as B1.append(B2).
- bagA bagA:: operator |= (bagA)
-
B1 |= B2 is the same as B1.append(B2).
- bagA bagA:: operator | (bagA)
-
B1 | B2 is the same as (+B1) |= B2.
- bagA bagA:: apply (void (*)(objA))
-
B.apply(F) passes each of its members to the function F.
- bagA bagA:: applyX (objA (*)(objA), bagA)
-
B1.apply(F, B2) passes each of its members to the function F, and inserts
the resulting obj into bag B2 (n.b. it modifies B2).
- bagA bagA:: applyX (bagA (*)(objA), bagA)
-
B1.apply(F, B2) passes each of its members to the function F, and appends
the resulting bag into bag B2 (n.b. it modifies B2).
- bagA bagA:: makeEmpty ()
-
B.makeEmpty() makes and returns an empty bag of the same type as B.
- bagA bagA:: make (objA (*)(objA))
-
B.make(F) is shorthand for B.applyX(F, B.makeEmpty()).
- bagA bagA:: make (bagA (*)(objA))
-
B.make(F) is shorthand for B.applyX(F, B.makeEmpty()).
INTERNAL OPERATIONS
- virtual int bagG:: isEmpty () const
-
G->isEmpty() returns TRUE if G has no members.
- virtual int bagG:: count () const
-
G->count() returns the number of members in G.
- virtual int bagG:: contains (objT*) const
-
G1->contains(G2) returns TRUE if a member of G1 is(G2); FALSE otherwise.
- virtual int bagG:: containsEqual (objT*) const
-
G1->contains(G2) returns TRUE if a member of G1 isEqual(G2); FALSE otherwise.
- virtual void bagG:: insert (objT*)
-
G1->insert(G2) inserts G2 into G1 (G2 may fall through or be transformed).
- virtual void bagG:: append (bagG*)
-
G1->append(G2) inserts each member of G2 into G1.
- virtual void bagG:: apply (void (*)(objA)) const
-
G1->apply(F) passes each member of G1 to function F.
- virtual bagG* bagG:: applyX (objA (*)(objA), bagG* B) const
-
G1->applyX(F, G2) passes each member of G1 to function F and inserts the
resulting obj into G2 (n.b. it modifies G2).
- virtual bagG* bagG:: applyX (bagA (*)(objA), bagG* B) const
-
G1->applyX(F, G2) passes each member of G1 to function F and appends the
resulting bag into G2 (n.b. it modifies G2).
- virtual bagA bagG:: makeEmpty () const
-
G->makeEmpty makes and returns an empty bag of the same type as G.
SEE ALSO
OATH(3O), obj(3O)
AUTHOR
Brian M. Kennedy (Computer Science Center, Texas Instruments Incorporated)
BUGS
Index
- NAME
-
- SYNOPSIS
-
- DESCRIPTION
-
- DERIVATION
-
- STATIC OPERATIONS
-
- MEMBER OPERATIONS
-
- INTERNAL OPERATIONS
-
- SEE ALSO
-
- AUTHOR
-
- BUGS
-
This document was created by
man2html,
using the manual pages.
Time: 20:37:46 GMT, July 24, 2024