public void Add(T arg) { SimpleListSector <T> newData = sectorStack.Get(); if (newData == null) { newData = new SimpleListSector <T>(); } newData.before = back; newData.next = null; newData.obj = arg; if (back != null) { back.next = newData; } back = newData; if (Count == 0) { forward = newData; } ++Count; }
public void Add(SimpleListSector <T> arg) { arg.obj = null; arg.before = null; arg.next = forward; forward = arg; }
public void Clear() { forward = back = null; Count = 0; sectorStack = new SimpleStack <T> { forward = null }; }
public SimpleListSector <T> Get() { if (forward == null) { return(null); } SimpleListSector <T> result = forward; forward = forward.next; return(result); }
public SimpleListSector <T> Delete_ReplaceNext() { if (Obj.next != null) { Obj.next.before = Obj.before; } if (Obj.before != null) { Obj.before.next = Obj.next; } var result = Obj; Obj = Obj.next; return(result); }
// 最善の要素を削除する いちいちイテレーター取得して云々するより早いと思う public void DeleteForward() { if (Count <= 1) { if (Count == 1) { sectorStack.Add(forward); } forward = back = null; Count = 0; return; } forward = forward.next; if (Count != 0) { sectorStack.Add(forward.before); } forward.before = null; --Count; }
// イテレーターには次の要素が格納される public void Delete(ref SimpleListIterator <T> iterator) { // if (Count <= 1) { if (Count == 1) { sectorStack.Add(iterator.Obj); } iterator.Obj = forward = back = null; Count = 0; return; } if (iterator.Obj.next == null) { back = iterator.Obj.before; } if (iterator.Obj.before == null) { forward = iterator.Obj.next; } sectorStack.Add(iterator.Delete_ReplaceNext()); --Count; }
public void Next() { Obj = Obj.next; }
public void Before() { Obj = Obj.before; }
public void AddBefore(SimpleListSector <T> arg) { before = arg; }
public void AddNext(SimpleListSector <T> arg) { next = arg; }
public void SetDefault() { before = next = null; }