Void testhash::Parent::cascadeRemoveTableListChild() const { Child prev; for ( Child current = getFirstTableListChild(); current.isValid(); current = current.getNextParentTableListChild()) { if (prev.isValid()) { prev.removeTableListParentHandler(); prev.destroy(); } prev = current; } if (prev.isValid()) { prev.removeTableListParentHandler(); prev.destroy(); } }
testhash::Child testhash::Parent::popFrontTableListChild() const { Child result = getFirstTableListChild(); if(result.isValid()) { result.removeTableListParentHandler(); Child next = result.getNextParentTableListChild(); result.setNextParentTableListChild(Child()); result.setPrevParentTableListChild(Child()); setFirstTableListChild(next); if(!next.isValid()) setLastTableListChild(Child()); else next.setPrevParentTableListChild(Child()); setNumTableListChilds(getNumTableListChilds() - 1); } return result; }
testhash::Child testhash::Parent::popBackTableListChild() const { Child result = getLastTableListChild(); if(result.isValid()) { result.removeTableListParentHandler(); Child prev = result.getPrevParentTableListChild(); result.setPrevParentTableListChild(Child()); result.setNextParentTableListChild(Child()); setLastTableListChild(prev); if(!prev.isValid()) setFirstTableListChild(Child()); else prev.setNextParentTableListChild(Child()); setNumTableListChilds(getNumTableListChilds() - 1); } return result; }
Bool testhash::Parent::removeTableListChild(const Child & child) const { if( !child.isExists()) return false; child.removeTableListParentHandler(); Child next = child.getNextParentTableListChild(), prev = child.getPrevParentTableListChild(); if(next.isValid()) next.setPrevParentTableListChild(prev); else if (getLastTableListChild() == child) setLastTableListChild(prev); else return false; if(prev.isValid()) prev.setNextParentTableListChild(next); else if (getFirstTableListChild() == child) setFirstTableListChild(next); else return false; child.setNextParentTableListChild(Child()); child.setPrevParentTableListChild(Child()); setNumTableListChilds(getNumTableListChilds() - 1); return true; }