Ejemplo n.º 1
0
        public OpStack Copy()
        {
            var _newOP = new OpStack();

            _newOP._index = this._index;
            _newOP._stack = this._stack.ToDictionary(i => i.Key, i => i.Value);;

            return(_newOP);
        }
Ejemplo n.º 2
0
        public OpStack PopRange(int _key_start, int _keyend)
        {
            var _op = new OpStack();

            var iterator = 0;

            do
            {
                var value = this.PopAt(_key_start + iterator);
                _op.PushAt(_key_start + iterator, value);
                iterator++;
            }while (_key_start + iterator <= _keyend);
            return(_op);
        }
Ejemplo n.º 3
0
        public void PushRipple(int RippleIndex, int growthFactor)
        {
            if (this.Count() == 0)
            {
                return;
            }


            OpStack _temp = new OpStack();

            #region SPREAD
            // HERE WE TAKE EVERYTHING ABOVE THE "RippleIndex" and Push it to a temp table with new keys pushed farther apart
            var next = this.PeekBottomKey();
            do
            {
                _temp.PushAt(next + growthFactor, this.PopAt(next));
                next = this.PeekBottomKey();
            } while (next > RippleIndex);
            #endregion

            #region GATHER
            next = _temp.PeekBottomKey();
            var min = -1;
            do
            {
                this.PushAt(next, _temp.PopAt(next));

                if (_temp.Count() > 0)
                {
                    next = _temp.PeekBottomKey();
                    min  = _temp._stack.Keys.Min();
                }
                else
                {
                    next = -1;
                }
            } while (next >= min && next != -1);

            #endregion
        }