System.Collections.Queue.Enqueue C# (CSharp) Method

Enqueue() public method

public Enqueue ( object obj ) : void
obj object
return void
        public virtual void Enqueue(object obj) { }
        public virtual System.Collections.IEnumerator GetEnumerator() { throw null; }

Same methods

Queue::Enqueue ( Object obj ) : void

Usage Example

Exemplo n.º 1
1
        private static void FillQueue(int firstX, int firstY, byte currColor, byte destColor)
        {
            Queue<Tuple<int, int>> q = new Queue<Tuple<int, int>>();
            q.Enqueue(Tuple.Create(firstX, firstY));

            var maxX = _data.GetLength(0);
                var maxY = _data.GetLength(1);
            while (q.Count > 0)
            {
                var point = q.Dequeue();
                var x = point.Item1;
                var y = point.Item2;

                if (_data[x, y] == destColor)
                    continue;
                if (_data[x, y] != currColor)
                    continue;

                _data[x, y] = destColor;

                if (x + 1 < maxX)
                    q.Enqueue(Tuple.Create(x + 1, y));
                if (x - 1 >= 0)
                    q.Enqueue(Tuple.Create(x - 1, y));

                if (y + 1 < maxY)
                    q.Enqueue(Tuple.Create(x, y + 1));
                if (y - 1 >= 0)
                    q.Enqueue(Tuple.Create(x, y - 1));

                Display(_data);
            }
        }
All Usage Examples Of System.Collections.Queue::Enqueue