next up previous contents
Next: The GnodePtrBagIter Class Implementation: Up: The Bag Classes: Previous: The GnodePtrBagLink Class Implementation:

The GnodePtrBag Class Implementation:

Next, we define the GnodePtrBag class itself.

GnodePtrBag::GnodePtrBag(const GnodePtrBag& T)
{
  d_root_p = T.d_root_p;
}

GnodePtrBag::GnodePtrBag()
{
  d_root_p = NULL;
}

GnodePtrBag& GnodePtrBag::operator=(const GnodePtrBag& T)
{
  if(&T!=this){
    d_root_p = T.d_root_p;
    return(*this);
    }
  else{
    return(*this);
    }
}

GnodePtrBag::~GnodePtrBag()
{  
   GnodePtrBagManip man(this);
   while(man){
     man.remove();
     }
}

void GnodePtrBag::add(Gnode *pointer)
{
  d_root_p = new GnodePtrBagLink(pointer,d_root_p);
}

void GnodePtrBag::removeAll(const Gnode *pointer)
{
  GnodePtrBagManip man(this);
  while(man){
    man()==pointer ? man.remove() : man.advance();
    }
}



Jim Peterson
1999-05-17