Exemple #1
0
    public int CopyTo(T[] array, int arrayIndex, int count)
    {
        if (!this.any)
        {
            return(0);
        }
        ODBNode <T> oDBNode = this.first.item;
        int         num     = -1;

        if (count > this.count)
        {
            count = this.count;
        }
        while (true)
        {
            int num1 = num + 1;
            num = num1;
            if (num1 >= count)
            {
                break;
            }
            int num2 = arrayIndex;
            arrayIndex  = num2 + 1;
            array[num2] = oDBNode.self;
            oDBNode     = oDBNode.n.item;
        }
        return(num);
    }
Exemple #2
0
 protected bool DoRemove(ref ODBNode <T> node)
 {
     if (this.any && (node.list == this))
     {
         this.hashSet.Remove(node.self);
         node.Dispose();
         node = null;
         return(true);
     }
     return(false);
 }
Exemple #3
0
 protected bool DoRemove(ref ODBNode <T> node)
 {
     if (!this.any || node.list != this)
     {
         return(false);
     }
     this.hashSet.Remove(node.self);
     node.Dispose();
     node = null;
     return(true);
 }
Exemple #4
0
 public bool MoveNext()
 {
     if (this.sib.has)
     {
         ODBNode <T> item = this.sib.item;
         this.Current = item.self;
         this.sib     = item.p;
         return(true);
     }
     return(false);
 }
Exemple #5
0
    public static ODBNode <T> New(ODBList <T> list, T self)
    {
        ODBNode <T> node;

        if (!ODBNode <T> .recycle.Pop(out node))
        {
            node = new ODBNode <T>();
        }
        node.Setup(list, self);
        return(node);
    }
Exemple #6
0
    public bool MoveNext()
    {
        if (!this.sib.has)
        {
            return(false);
        }
        ODBNode <T> oDBNode = this.sib.item;

        this.Current = oDBNode.self;
        this.sib     = oDBNode.p;
        return(true);
    }
Exemple #7
0
    protected bool DoAdd(T item)
    {
        if (!item)
        {
            throw new MissingReferenceException("You cannot pass a missing or null item into the list");
        }
        if (!this.hashSet.Add(item))
        {
            return(false);
        }
        ODBNode <T> .New(this, item);

        return(true);
    }
Exemple #8
0
    protected bool DoAdd(T item, out ODBNode <T> node)
    {
        if (item == null)
        {
            throw new MissingReferenceException("You cannot pass a missing or null item into the list");
        }
        if (this.hashSet.Add(item))
        {
            node = ODBNode <T> .New((ODBList <T>) this, item);

            return(true);
        }
        node = null;
        return(false);
    }
Exemple #9
0
 protected void DoUnionWith(ODBList <T> list)
 {
     if (list.any && (list != this))
     {
         ODBSibling <T> first = list.first;
         do
         {
             T self = first.item.self;
             first = first.item.n;
             if (this.hashSet.Add(self))
             {
                 ODBNode <T> .New((ODBList <T>) this, self);
             }
         }while (first.has);
     }
 }
Exemple #10
0
 public bool Pop(out ODBNode <T> o)
 {
     o = this.items;
     if (!this.any)
     {
         return(false);
     }
     if (--this.count == 0)
     {
         this.any   = false;
         this.items = null;
     }
     else
     {
         this.items = o.n.item;
     }
     return(true);
 }
Exemple #11
0
    protected void DoUnionWith(ODBList <T> list)
    {
        if (!list.any || list == this)
        {
            return;
        }
        ODBSibling <T> oDBSibling = list.first;

        do
        {
            T t = oDBSibling.item.self;
            oDBSibling = oDBSibling.item.n;
            if (!this.hashSet.Add(t))
            {
                continue;
            }
            ODBNode <T> .New(this, t);
        }while (oDBSibling.has);
    }
Exemple #12
0
 public void Push(ODBNode <T> item)
 {
     item.list = null;
     item.self = null;
     if (this.any)
     {
         item.n.item = this.items;
         item.n.has  = true;
         this.items  = item;
         this.count++;
     }
     else
     {
         item.n     = new ODBSibling <T>();
         this.items = item;
         this.count = 1;
         this.any   = true;
     }
 }
Exemple #13
0
 protected void DoSymmetricExceptWith(ODBList <T> list)
 {
     if (this.any)
     {
         if (list.any)
         {
             if (list == this)
             {
                 this.DoClear();
             }
             else
             {
                 ODBSibling <T> first = list.first;
                 do
                 {
                     T self = first.item.self;
                     first = first.item.n;
                     if (this.hashSet.Remove(self))
                     {
                         this.KnownFind(self).Dispose();
                     }
                     else
                     {
                         this.hashSet.Add(self);
                         ODBNode <T> .New((ODBList <T>) this, self);
                     }
                 }while (first.has);
             }
         }
     }
     else if (list.any)
     {
         ODBSibling <T> n = list.first;
         do
         {
             T item = n.item.self;
             n = n.item.n;
             this.hashSet.Add(item);
             ODBNode <T> .New((ODBList <T>) this, item);
         }while (n.has);
     }
 }
Exemple #14
0
 protected void DoIntersectWith(ODBList <T> list)
 {
     if (this.any)
     {
         if (list.any)
         {
             if (list != this)
             {
                 this.hashSet.IntersectWith(list.hashSet);
                 int count = this.hashSet.Count;
                 if (count == 0)
                 {
                     while (this.any)
                     {
                         this.first.item.Dispose();
                     }
                 }
                 else
                 {
                     ODBSibling <T> first = this.first;
                     do
                     {
                         ODBNode <T> item = first.item;
                         first = first.item.n;
                         if (!this.hashSet.Contains(item.self))
                         {
                             item.Dispose();
                             if (this.count == count)
                             {
                                 break;
                             }
                         }
                     }while (first.has);
                 }
             }
         }
         else
         {
             this.DoClear();
         }
     }
 }
Exemple #15
0
 protected void DoSymmetricExceptWith(ODBList <T> list)
 {
     if (this.any)
     {
         if (list.any)
         {
             if (list != this)
             {
                 ODBSibling <T> oDBSibling = list.first;
                 do
                 {
                     T t = oDBSibling.item.self;
                     oDBSibling = oDBSibling.item.n;
                     if (!this.hashSet.Remove(t))
                     {
                         this.hashSet.Add(t);
                         ODBNode <T> .New(this, t);
                     }
                     else
                     {
                         this.KnownFind(t).Dispose();
                     }
                 }while (oDBSibling.has);
             }
             else
             {
                 this.DoClear();
             }
         }
     }
     else if (list.any)
     {
         ODBSibling <T> oDBSibling1 = list.first;
         do
         {
             T t1 = oDBSibling1.item.self;
             oDBSibling1 = oDBSibling1.item.n;
             this.hashSet.Add(t1);
             ODBNode <T> .New(this, t1);
         }while (oDBSibling1.has);
     }
 }
Exemple #16
0
    public int CopyTo(T[] array, int arrayIndex, int count)
    {
        if (!this.any)
        {
            return(0);
        }
        ODBNode <T> item = this.first.item;
        int         num  = -1;

        if (count > this.count)
        {
            count = this.count;
        }
        while (++num < count)
        {
            array[arrayIndex++] = item.self;
            item = item.n.item;
        }
        return(num);
    }
Exemple #17
0
 public void Push(ODBNode <T> item)
 {
     item.list = null;
     item.self = (T)null;
     if (!this.any)
     {
         item.n     = new ODBSibling <T>();
         this.items = item;
         this.count = 1;
         this.any   = true;
     }
     else
     {
         item.n.item = this.items;
         item.n.has  = true;
         this.items  = item;
         ODBNode <T> .Recycler recycler = this;
         recycler.count = recycler.count + 1;
     }
 }
Exemple #18
0
 protected void DoIntersectWith(ODBList <T> list)
 {
     if (this.any)
     {
         if (!list.any)
         {
             this.DoClear();
         }
         else if (list != this)
         {
             this.hashSet.IntersectWith(list.hashSet);
             int count = this.hashSet.Count;
             if (count != 0)
             {
                 ODBSibling <T> oDBSibling = this.first;
                 do
                 {
                     ODBNode <T> oDBNode = oDBSibling.item;
                     oDBSibling = oDBSibling.item.n;
                     if (this.hashSet.Contains(oDBNode.self))
                     {
                         continue;
                     }
                     oDBNode.Dispose();
                     if (this.count != count)
                     {
                         continue;
                     }
                     break;
                 }while (oDBSibling.has);
             }
             else
             {
                 while (this.any)
                 {
                     this.first.item.Dispose();
                 }
             }
         }
     }
 }
Exemple #19
0
        public bool Pop(out ODBNode <T> o)
        {
            o = this.items;
            if (!this.any)
            {
                return(false);
            }
            ODBNode <T> .Recycler recycler = this;
            int num  = recycler.count - 1;
            int num1 = num;

            recycler.count = num;
            if (num1 != 0)
            {
                this.items = o.n.item;
            }
            else
            {
                this.any   = false;
                this.items = null;
            }
            return(true);
        }
Exemple #20
0
 public ODBForwardEnumerator(ODBNode <T> node)
 {
     this.sib.has  = true;
     this.sib.item = node;
     this.Current  = (T)null;
 }
Exemple #21
0
 public bool Contains(ODBNode <T> item)
 {
     return(this.any && (item.list == this));
 }
Exemple #22
0
 public ODBForwardEnumerable(ODBNode <T> node)
 {
     this.sibling.has  = true;
     this.sibling.item = node;
 }
Exemple #23
0
 public bool Remove(ref ODBNode <T> node)
 {
     return(base.DoRemove(ref node));
 }
Exemple #24
0
 public bool Add(T item, out ODBNode <T> node)
 {
     return(base.DoAdd(item, out node));
 }
Exemple #25
0
 internal ODBItem(ODBNode <TItem> node)
 {
     this.node = node;
 }
 public ODBReverseEnumerable(ODBNode <T> node)
 {
     this.sibling.has  = true;
     this.sibling.item = node;
 }
Exemple #27
0
 public ODBReverseEnumerator(ODBNode <T> node)
 {
     this.sib.has  = true;
     this.sib.item = node;
     this.Current  = null;
 }
Exemple #28
0
 public bool Contains(ODBNode <T> item)
 {
     return(!this.any ? false : item.list == this);
 }