예제 #1
0
    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;
    }
예제 #2
0
 public void Add(SimpleListSector <T> arg)
 {
     arg.obj    = null;
     arg.before = null;
     arg.next   = forward;
     forward    = arg;
 }
예제 #3
0
 public void Clear()
 {
     forward     = back = null;
     Count       = 0;
     sectorStack = new SimpleStack <T> {
         forward = null
     };
 }
예제 #4
0
    public SimpleListSector <T> Get()
    {
        if (forward == null)
        {
            return(null);
        }
        SimpleListSector <T> result = forward;

        forward = forward.next;
        return(result);
    }
예제 #5
0
    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);
    }
예제 #6
0
 // 最善の要素を削除する いちいちイテレーター取得して云々するより早いと思う
 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;
 }
예제 #7
0
 // イテレーターには次の要素が格納される
 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;
 }
예제 #8
0
 public void Next()
 {
     Obj = Obj.next;
 }
예제 #9
0
 public void Before()
 {
     Obj = Obj.before;
 }
예제 #10
0
 public void AddBefore(SimpleListSector <T> arg)
 {
     before = arg;
 }
예제 #11
0
 public void AddNext(SimpleListSector <T> arg)
 {
     next = arg;
 }
예제 #12
0
 public void SetDefault()
 {
     before = next = null;
 }