Esempio n. 1
0
            internal static StaticQueue <KEY, T> .node insert_end(StaticQueue <KEY, T> .node node)
            {
                if (node.e)
                {
                    StaticQueue <KEY, T> .reg.deref(node);
                }
                int num = StaticQueue <KEY, T> .count;

                StaticQueue <KEY, T> .count = num + 1;
                if (num != 0)
                {
                    node.w.p.e = true;
                    node.w.p.v = StaticQueue <KEY, T> .reg.last;
                    StaticQueue <KEY, T> .reg.last.w.n.e = true;
                    StaticQueue <KEY, T> .reg.last.w.n.v = node;
                    StaticQueue <KEY, T> .reg.last       = node;
                }
                else
                {
                    StaticQueue <KEY, T> .node _node = node;
                    StaticQueue <KEY, T> .reg.first = _node;
                    StaticQueue <KEY, T> .reg.last  = _node;
                }
                node.e = true;
                return(StaticQueue <KEY, T> .reg.last);
            }
Esempio n. 2
0
 public iterator(int maxIterations, int maxFailedIterations)
 {
     StaticQueue <KEY, T> .node _node;
     if (maxIterations == 0 || maxIterations > StaticQueue <KEY, T> .count)
     {
         this.attempts  = StaticQueue <KEY, T> .count;
         this.fail_left = 0;
     }
     else if (maxIterations == StaticQueue <KEY, T> .count)
     {
         this.attempts  = StaticQueue <KEY, T> .count;
         this.fail_left = 0;
     }
     else if (maxIterations + maxFailedIterations <= StaticQueue <KEY, T> .count)
     {
         this.attempts  = maxIterations;
         this.fail_left = maxFailedIterations;
     }
     else
     {
         this.attempts  = maxIterations;
         this.fail_left = StaticQueue <KEY, T> .count - maxIterations;
     }
     this.position = 0;
     this.node     = null;
     if (!StaticQueue <KEY, T> .reg_made)
     {
         _node = null;
     }
     else
     {
         _node = StaticQueue <KEY, T> .reg.first;
     }
     this.next = _node;
 }
            // Token: 0x06000C9A RID: 3226 RVA: 0x000305A4 File Offset: 0x0002E7A4
            internal static StaticQueue <KEY, T> .node insert_begin(StaticQueue <KEY, T> .node node)
            {
                if (node.e)
                {
                    StaticQueue <KEY, T> .reg.deref(node);
                }
                int count = StaticQueue <KEY, T> .count;

                StaticQueue <KEY, T> .count = count + 1;
                if (count == 0)
                {
                    StaticQueue <KEY, T> .reg.first = node;
                    StaticQueue <KEY, T> .reg.last  = node;
                }
                else
                {
                    node.w.n.e = true;
                    node.w.n.v = StaticQueue <KEY, T> .reg.first;
                    StaticQueue <KEY, T> .reg.first.w.p.e = true;
                    StaticQueue <KEY, T> .reg.first.w.p.v = node;
                    StaticQueue <KEY, T> .reg.first       = node;
                }
                node.e = true;
                return(StaticQueue <KEY, T> .reg.first);
            }
Esempio n. 4
0
 protected static bool dequeue(T instance, ref StaticQueue <KEY, T> .Entry state)
 {
     if (!state.inside)
     {
         return(false);
     }
     state.inside = false;
     return(StaticQueue <KEY, T> .reg.dispose(ref state.node));
 }
            // Token: 0x06000CA4 RID: 3236 RVA: 0x00030A0C File Offset: 0x0002EC0C
            public bool Next(ref StaticQueue <KEY, T> .Entry prev_key, StaticQueue <KEY, T> .act cmd, out T v)
            {
                bool flag = object.ReferenceEquals(prev_key.node, null);

                if (!flag && !object.ReferenceEquals(prev_key.node, this.node))
                {
                    throw new ArgumentException("prev_key did not match that of what was expected", "prev_key");
                }
                if (flag)
                {
                    prev_key.inside = false;
                }
                if (!prev_key.inside)
                {
                    cmd = StaticQueue <KEY, T> .act.delist;
                    if (this.fail_left-- > 0)
                    {
                        this.position--;
                    }
                    if (flag)
                    {
                        StaticQueue <KEY, T> .reg.dispose(ref this.node);
                    }
                    else
                    {
                        StaticQueue <KEY, T> .reg.dispose(ref prev_key.node);
                    }
                }
                else
                {
                    switch (cmd)
                    {
                    case StaticQueue <KEY, T> .act.front:
                        if (StaticQueue <KEY, T> .reg.deref(this.node))
                        {
                            prev_key.node = StaticQueue <KEY, T> .reg.insert_begin(this.node);
                        }
                        break;

                    case StaticQueue <KEY, T> .act.back:
                        if (StaticQueue <KEY, T> .reg.deref(this.node))
                        {
                            prev_key.node = StaticQueue <KEY, T> .reg.insert_end(this.node);
                        }
                        break;

                    case StaticQueue <KEY, T> .act.delist:
                        StaticQueue <KEY, T> .reg.dispose(ref this.node);

                        prev_key.node = null;
                        break;
                    }
                }
                return(this.Start(out v));
            }
Esempio n. 6
0
        protected static bool enqueue(T instance, ref StaticQueue <KEY, T> .Entry state)
        {
            if (state.inside)
            {
                return(false);
            }
            state.inside = true;
            state.node   = StaticQueue <KEY, T> .reg.insert_end(StaticQueue <KEY, T> .reg.make_node(instance));

            return(true);
        }
            // Token: 0x06000C99 RID: 3225 RVA: 0x00030534 File Offset: 0x0002E734
            internal static void delete(StaticQueue <KEY, T> .node r)
            {
                r.v   = (T)((object)null);
                r.w.n = default(StaticQueue <KEY, T> .way);
                r.e   = false;
                int num = StaticQueue <KEY, T> .reg.dump_size;

                StaticQueue <KEY, T> .reg.dump_size = num + 1;
                r.w.p.e = (num > 0);
                r.w.p.v = StaticQueue <KEY, T> .reg.dump;
                StaticQueue <KEY, T> .reg.dump = r;
            }
Esempio n. 8
0
            internal static bool dispose(ref StaticQueue <KEY, T> .node node)
            {
                if (!StaticQueue <KEY, T> .reg.deref(node))
                {
                    return(false);
                }
                node.v = (T)null;
                StaticQueue <KEY, T> .reg.delete(node);

                node = null;
                return(true);
            }
            // Token: 0x06000C9D RID: 3229 RVA: 0x00030820 File Offset: 0x0002EA20
            internal static bool dispose(ref StaticQueue <KEY, T> .node node)
            {
                if (StaticQueue <KEY, T> .reg.deref(node))
                {
                    node.v = (T)((object)null);
                    StaticQueue <KEY, T> .reg.delete(node);

                    node = null;
                    return(true);
                }
                return(false);
            }
Esempio n. 10
0
            internal static void delete(StaticQueue <KEY, T> .node r)
            {
                r.v = (T)null;
                StaticQueue <KEY, T> .way _way = new StaticQueue <KEY, T> .way();

                r.w.n = _way;
                r.e   = false;
                int dumpSize = StaticQueue <KEY, T> .reg.dump_size;

                StaticQueue <KEY, T> .reg.dump_size = dumpSize + 1;
                r.w.p.e = dumpSize > 0;
                r.w.p.v = StaticQueue <KEY, T> .reg.dump;
                StaticQueue <KEY, T> .reg.dump = r;
            }
Esempio n. 11
0
        protected static bool requeue(T instance, ref StaticQueue <KEY, T> .Entry state)
        {
            if (!state.inside)
            {
                return(false);
            }
            if (object.ReferenceEquals(StaticQueue <KEY, T> .reg.last, state.node))
            {
                return(true);
            }
            state.node = StaticQueue <KEY, T> .reg.insert_end(state.node);

            return(true);
        }
Esempio n. 12
0
        protected static bool validate(T instance, ref StaticQueue <KEY, T> .Entry state, bool must_be_contained = false)
        {
            bool mustBeContained;

            if (!state.inside)
            {
                mustBeContained = !must_be_contained;
            }
            else
            {
                mustBeContained = (object.ReferenceEquals(state.node, null) ? false : object.ReferenceEquals(state.node.v, instance));
            }
            return(mustBeContained);
        }
Esempio n. 13
0
            public bool MissingNext(out T v)
            {
                StaticQueue <KEY, T> .iterator _iterator = this;
                int failLeft = _iterator.fail_left;
                int num      = failLeft;

                _iterator.fail_left = failLeft - 1;
                if (num > 0)
                {
                    StaticQueue <KEY, T> .iterator _iterator1 = this;
                    _iterator1.position = _iterator1.position - 1;
                }
                StaticQueue <KEY, T> .reg.dispose(ref this.node);

                return(this.Start(out v));
            }
 // Token: 0x06000C98 RID: 3224 RVA: 0x000304CC File Offset: 0x0002E6CC
 internal static StaticQueue <KEY, T> .node make_node(T v)
 {
     StaticQueue <KEY, T> .node node;
     if (StaticQueue <KEY, T> .reg.dump_size > 0)
     {
         StaticQueue <KEY, T> .reg.dump_size--;
         node = StaticQueue <KEY, T> .reg.dump;
         StaticQueue <KEY, T> .reg.dump = node.w.p.v;
         node.w = default(StaticQueue <KEY, T> .fork);
     }
     else
     {
         node = new StaticQueue <KEY, T> .node();
     }
     node.v = v;
     node.e = false;
     return(node);
 }
Esempio n. 15
0
 internal static StaticQueue <KEY, T> .node make_node(T v)
 {
     StaticQueue <KEY, T> .node _node;
     if (StaticQueue <KEY, T> .reg.dump_size <= 0)
     {
         _node = new StaticQueue <KEY, T> .node();
     }
     else
     {
         StaticQueue <KEY, T> .reg.dump_size = StaticQueue <KEY, T> .reg.dump_size - 1;
         _node = StaticQueue <KEY, T> .reg.dump;
         StaticQueue <KEY, T> .reg.dump = _node.w.p.v;
         _node.w = new StaticQueue <KEY, T> .fork();
     }
     _node.v = v;
     _node.e = false;
     return(_node);
 }
Esempio n. 16
0
            internal static bool deref(StaticQueue <KEY, T> .node node)
            {
                if (object.ReferenceEquals(node, null))
                {
                    return(false);
                }
                if (!node.e)
                {
                    return(false);
                }
                int num = StaticQueue <KEY, T> .count - 1;

                StaticQueue <KEY, T> .count = num;
                if (num != 0)
                {
                    if (node.w.p.e)
                    {
                        node.w.p.v.w.n = node.w.n;
                    }
                    else if (node.w.n.e)
                    {
                        StaticQueue <KEY, T> .reg.first = node.w.n.v;
                    }
                    if (node.w.n.e)
                    {
                        node.w.n.v.w.p = node.w.p;
                    }
                    else if (node.w.p.e)
                    {
                        StaticQueue <KEY, T> .reg.last = node.w.p.v;
                    }
                    node.w = new StaticQueue <KEY, T> .fork();
                }
                else
                {
                    object obj = null;
                    StaticQueue <KEY, T> .reg.last  = (StaticQueue <KEY, T> .node)obj;
                    StaticQueue <KEY, T> .reg.first = (StaticQueue <KEY, T> .node)obj;
                }
                node.e = false;
                return(true);
            }
Esempio n. 17
0
            public bool Start(out T v)
            {
                StaticQueue <KEY, T> .iterator _iterator = this;
                int num  = _iterator.position;
                int num1 = num;

                _iterator.position = num + 1;
                if (num1 >= this.attempts)
                {
                    object obj = null;
                    StaticQueue <KEY, T> .node _node = (StaticQueue <KEY, T> .node)obj;
                    this.next = (StaticQueue <KEY, T> .node)obj;
                    this.node = _node;
                    v         = (T)null;
                    return(false);
                }
                this.node = this.next;
                this.next = this.node.w.n.v;
                v         = this.node.v;
                return(true);
            }
 // Token: 0x06000C9C RID: 3228 RVA: 0x000306EC File Offset: 0x0002E8EC
 internal static bool deref(StaticQueue <KEY, T> .node node)
 {
     if (object.ReferenceEquals(node, null))
     {
         return(false);
     }
     if (node.e)
     {
         if (--StaticQueue <KEY, T> .count == 0)
         {
             StaticQueue <KEY, T> .reg.first = (StaticQueue <KEY, T> .reg.last = null);
         }
         else
         {
             if (node.w.p.e)
             {
                 node.w.p.v.w.n = node.w.n;
             }
             else if (node.w.n.e)
             {
                 StaticQueue <KEY, T> .reg.first = node.w.n.v;
             }
             if (node.w.n.e)
             {
                 node.w.n.v.w.p = node.w.p;
             }
             else if (node.w.p.e)
             {
                 StaticQueue <KEY, T> .reg.last = node.w.p.v;
             }
             node.w = default(StaticQueue <KEY, T> .fork);
         }
         node.e = false;
         return(true);
     }
     return(false);
 }
Esempio n. 19
0
 protected static bool requeue(T instance, ref StaticQueue <KEY, T> .Entry state, bool enqueue_if_missing)
 {
     return(!enqueue_if_missing ? StaticQueue <KEY, T> .enqueue(instance, ref state) : StaticQueue <KEY, T> .enrequeue(instance, ref state));
 }
Esempio n. 20
0
 protected static bool enrequeue(T instance, ref StaticQueue <KEY, T> .Entry state)
 {
     return(!state.inside ? StaticQueue <KEY, T> .enqueue(instance, ref state) : StaticQueue <KEY, T> .requeue(instance, ref state));
 }
 // Token: 0x06000CA0 RID: 3232 RVA: 0x00030918 File Offset: 0x0002EB18
 public iterator(int maxIter)
 {
     this = new StaticQueue <KEY, T> .iterator(maxIter, (maxIter >= StaticQueue <KEY, T> .count)? 0 : (StaticQueue <KEY, T> .count - maxIter));
 }
 // Token: 0x06000C8D RID: 3213 RVA: 0x00030370 File Offset: 0x0002E570
 protected static bool validate(T instance, ref StaticQueue <KEY, T> .Entry state, bool must_be_contained = false)
 {
     return((!state.inside) ? (!must_be_contained) : (!object.ReferenceEquals(state.node, null) && object.ReferenceEquals(state.node.v, instance)));
 }
Esempio n. 23
0
            public bool Next(ref StaticQueue <KEY, T> .Entry prev_key, StaticQueue <KEY, T> .act cmd, out T v)
            {
                bool flag = object.ReferenceEquals(prev_key.node, null);

                if (!flag && !object.ReferenceEquals(prev_key.node, this.node))
                {
                    throw new ArgumentException("prev_key did not match that of what was expected", "prev_key");
                }
                if (flag)
                {
                    prev_key.inside = false;
                }
                if (prev_key.inside)
                {
                    switch (cmd)
                    {
                    case (StaticQueue <KEY, T> .act)StaticQueue <KEY, T> .act.front:
                    {
                        if (StaticQueue <KEY, T> .reg.deref(this.node))
                        {
                            prev_key.node = StaticQueue <KEY, T> .reg.insert_begin(this.node);
                        }
                        break;
                    }

                    case (StaticQueue <KEY, T> .act)StaticQueue <KEY, T> .act.back:
                    {
                        if (StaticQueue <KEY, T> .reg.deref(this.node))
                        {
                            prev_key.node = StaticQueue <KEY, T> .reg.insert_end(this.node);
                        }
                        break;
                    }

                    case (StaticQueue <KEY, T> .act)StaticQueue <KEY, T> .act.delist:
                    {
                        StaticQueue <KEY, T> .reg.dispose(ref this.node);

                        prev_key.node = null;
                        break;
                    }
                    }
                }
                else
                {
                    cmd = StaticQueue <KEY, T> .act.delist;
                    StaticQueue <KEY, T> .iterator _iterator = this;
                    int failLeft = _iterator.fail_left;
                    int num      = failLeft;
                    _iterator.fail_left = failLeft - 1;
                    if (num > 0)
                    {
                        StaticQueue <KEY, T> .iterator _iterator1 = this;
                        _iterator1.position = _iterator1.position - 1;
                    }
                    if (!flag)
                    {
                        StaticQueue <KEY, T> .reg.dispose(ref prev_key.node);
                    }
                    else
                    {
                        StaticQueue <KEY, T> .reg.dispose(ref this.node);
                    }
                }
                return(this.Start(out v));
            }
Esempio n. 24
0
 protected static bool contains(ref StaticQueue <KEY, T> .Entry state)
 {
     return(state.inside);
 }
Esempio n. 25
0
 public bool Validate(ref StaticQueue <KEY, T> .Entry key)
 {
     return(key.inside);
 }