public PageRecord ReplaceExistingPageWithNewPage(Page oldPage, int newPageid) { Page newPage = new Page(newPageid); Referenced = newPageid; PageFault = true; int indexInPageList = -1; foreach (Page page in Pages) { if (oldPage.PageNumber == page.PageNumber) { indexInPageList = Pages.IndexOf(page); } } if (indexInPageList >= 0) { if (Pages.Count + 1 > maxSize) { Pages.RemoveAt(indexInPageList); } Pages.Insert(indexInPageList, newPage); } return (PageRecord)this; }
public PageRecord CreateNewPageByPageNumberAndShiftTheOtherPages (int id) { Page newPage = new Page(id); Pages.Insert(0, newPage); Referenced = id; PageFault = true; if (Pages.Count > maxSize) { for (int i = maxSize; i <= Pages.Count; i++) { Pages.RemoveAt(i); } } return (PageRecord)this; }