next up previous contents
Next: The Node Bag Definitions: Up: The Bag Classes: Previous: The GedgePtrBagIter Class Implementation:

The GedgePtrBagmanip Class Implementation:

Finally, the GedgePtrBagManip class gives us the tools for edge pointer bag manipulations such as adding links and checking to see if links are the same. We have discussed this implementation at length already, but it is good to have all the source listed once and for all.

GedgePtrBagManip::GedgePtrBagManip(const GedgePtrBagManip& T)
{
  d_addrLink_p = T.d_addrLink_p;
  L = T.L;
}

GedgePtrBagManip& GedgePtrBagManip::operator=(const GedgePtrBagManip& T)
{
  if(&T!=this){
    d_addrLink_p = T.d_addrLink_p;
    L = T.L;
    return(*this);
    }
  else{
    return(*this);
    }
}

GedgePtrBagManip::GedgePtrBagManip(GedgePtrBag* bag)
{
  d_addrLink_p = &(bag->d_root_p);
  L = *d_addrLink_p;
}

GedgePtrBagManip::~GedgePtrBagManip()
{}

void GedgePtrBagManip::advance()
{
  L = L->next();
}

void GedgePtrBagManip::remove()
{
  GedgePtrBagLink *tmp = L; 
  L = L->next();
  
  GedgePtrBagLink *Now = *d_addrLink_p;
  GedgePtrBagLink *Prev;
  
  if(tmp==Now){
    *d_addrLink_p = (*d_addrLink_p)->next();
    delete Now;
    }
  else{
    Prev = Now;
    Now = Now->next();     
    while( !(Now==tmp) ){
      Prev = Now;
      Now = Now->next();    
      }    
    Prev->d_next_p = Now->next(); 
    delete Now;      
    }
}

Gedge *GedgePtrBagManip::operator()() const
{
  if(L!=NULL)
    return L->d_pointer_p;  
}

GedgePtrBagManip::operator const void *() const
{
  if(L==NULL) return (const void *)0;
  else return (const void *)1;  
}



Jim Peterson
1999-05-17