#ifndef _BAG_H_
#define _BAG_H_
/* - - - - - - - - - - - - - - - - - - - - - - - - - - */
class bag: public container {
private:
protected:
Bool is_head(entity * ENT); // check if ENT is the head element
element * previous(entity * ENT); // get to the element preceeding
an occurrent of ENT
element * previous(char * NAME); //get to the element preceding one
with this NAME
void remove_head(); // remove the head
void remove_middle(entity * ENT); // remove from the middle
void remove_middle(char * NAME);
public:
bag();
~bag();
int number_of(entity * ENT); // how many occurrences of ENT are in
container?
int number_of(char * NAME);
void remove(entity * ENT); // remove an occurrence of ENT from container,
if any
void remove(char * NAME);
void remove_all(entity * ENT); // remove all occurrences of ENT
void remove_all(char * NAME);
bag * container_to_bag(container * c); //convert a container to an
equivalent bag
};
#endif
Since a bag can hold multiple occurrences of the same object, there
are functions, number_of(entity * ENT) and number_of(char * NAME), to return
this number.