// History.cpp: implementation of the History class. // ////////////////////////////////////////////////////////////////////// #include "stdafx.h" #include "History.h" ////////////////////////////////////////////////////////////////////// // Construction/Destruction ////////////////////////////////////////////////////////////////////// History::History() { head = tail = NULL; } History::~History() { clear(); } long History::find(Generation* pg) { Record *p = head; while(p) { if(*pg == *p->pg) return p->step; p = p->next; } return -1; } void History::append(Generation* pg, long step) { Record *p = new Record(); p->pg = pg; p->step = step; p->next = NULL; if(head) { tail->next = p; tail = p; } else head = tail = p; } void History::clear() { Record *p = head, *temp; while(p) { temp = p->next; delete p->pg; delete p; p = temp; } head = tail = NULL; }