Exemple #1
0
        /// <include file='doc\Stack.uex' path='docs/doc[@for="Stack.Contains"]/*' />
        public bool Contains(T item)
        {
            int count = _size;

            EqualityComparer <T> c = EqualityComparer <T> .Default;

            while (count-- > 0)
            {
                if (((Object)item) == null)
                {
                    if (((Object)_array[count]) == null)
                    {
                        return(true);
                    }
                }
                else if (_array[count] != null && c.Equals(_array[count], item))
                {
                    return(true);
                }
            }
            return(false);
        }
Exemple #2
0
        public LinkedListNode <T> FindLast(T value)
        {
            if (head == null)
            {
                return(null);
            }

            LinkedListNode <T>   last = head.prev;
            LinkedListNode <T>   node = last;
            EqualityComparer <T> c    = EqualityComparer <T> .Default;

            if (node != null)
            {
                if (value != null)
                {
                    do
                    {
                        if (c.Equals(node.item, value))
                        {
                            return(node);
                        }

                        node = node.prev;
                    } while (node != last);
                }
                else
                {
                    do
                    {
                        if (node.item == null)
                        {
                            return(node);
                        }
                        node = node.prev;
                    } while (node != last);
                }
            }
            return(null);
        }
Exemple #3
0
        public ArrayLinkedListNode <T>?Find(T value)
        {
            if (_count == 0)
            {
                return(null);
            }

            ushort current = _first;
            EqualityComparer <T> comparer = EqualityComparer <T> .Default;

            while (current != Nil)
            {
                T currentValue = _items[current];
                if (comparer.Equals(value, currentValue))
                {
                    return(new ArrayLinkedListNode <T>(value: value, index: current, _version));
                }
                current = _next[current];
            }

            return(null);
        }
Exemple #4
0
        /// <summary>
        /// Determines whether an element is in the <see cref="T:System.Collections.Generic.Queue`1"/>.
        /// </summary>
        ///
        /// <returns>
        /// true if <paramref name="item"/> is found in the <see cref="T:System.Collections.Generic.Queue`1"/>; otherwise, false.
        /// </returns>
        /// <param name="item">The object to locate in the <see cref="T:System.Collections.Generic.Queue`1"/>. The value can be null for reference types.</param>
        public bool Contains(T item)
        {
            int index = this._head;
            int num   = this._size;
            EqualityComparer <T> @default = EqualityComparer <T> .Default;

            while (num-- > 0)
            {
                if ((object)item == null)
                {
                    if ((object)this._array[index] == null)
                    {
                        return(true);
                    }
                }
                else if ((object)this._array[index] != null && @default.Equals(this._array[index], item))
                {
                    return(true);
                }
                index = (index + 1) % this._array.Length;
            }
            return(false);
        }
Exemple #5
0
        public bool Contains(T item)
        {
            int index = this._head;
            int num2  = this._size;
            EqualityComparer <T> comparer = EqualityComparer <T> .Default;

            while (num2-- > 0)
            {
                if (item == null)
                {
                    if (this._array[index] == null)
                    {
                        return(true);
                    }
                }
                else if ((this._array[index] != null) && comparer.Equals(this._array[index], item))
                {
                    return(true);
                }
                index = (index + 1) % this._array.Length;
            }
            return(false);
        }
Exemple #6
0
        public bool Contains(T item)
        {
            if ((object)item == null)
            {
                for (int index = 0; index < this._size; ++index)
                {
                    if ((object)this._items[index] == null)
                    {
                        return(true);
                    }
                }
                return(false);
            }
            EqualityComparer <T> equalityComparer = EqualityComparer <T> .Default;

            for (int index = 0; index < this._size; ++index)
            {
                if (equalityComparer.Equals(this._items[index], item))
                {
                    return(true);
                }
            }
            return(false);
        }
Exemple #7
0
        public bool Contains(T item)
        {
            if (item == null)
            {
                for (int j = 0; j < this._size; j++)
                {
                    if (this._items[j] == null)
                    {
                        return(true);
                    }
                }
                return(false);
            }
            EqualityComparer <T> comparer = EqualityComparer <T> .Default;

            for (int i = 0; i < this._size; i++)
            {
                if (comparer.Equals(this._items[i], item))
                {
                    return(true);
                }
            }
            return(false);
        }