Relation Class

Relation is another kind of container. Instead of element, it uses pair as the storage basis. Class pair is basically similar to class element except that it has two pointers to entity. The declaration of class relation is:

#ifndef _RELATION_H_
#define _RELATION_H__
/* - - - - - - - - - - - - - - - - - - - - - - - - - - */

class relation : public set {
private:
protected:
pair * next_key( entity *ent, pair *start ); // to next occurrence of ent as a key
// from start position
pair * next_key_name( char * name, pair * start );
public:
relation();
~relation();
Bool key_is_in(entity * key); // is the key in relation?
Bool key_name_is_in(char * key); // is there a key with this name
void add( entity * key, entity * value ); // add key,value pair
void add(char * key, entity * value); // make a key with the given name and pair it
// with value
void remove( entity * key, entity * value ); // remove key,value pair
void remove(char * key, entity * value ); // remove pair with this name as key
void remove_all( entity * ent ); // remove all pairs with ent as key
entity * assoc( entity * key ); // what is the value associated with key?
entity * assoc(char * key); // what is the value associated with this name?
set * assoc_all( entity * key ); // collect all the values associated with key
set * assoc_all(char * key); //
set * range_objects(); // collects all the values
container * range_names(); // collects all the names of values
set * domain_objects(); // collects all the keys
container * domain_names(); // collects all the key names

};
#endif