hwstack.cs

来自「Freetextbox是优秀的在线编辑器」· CS 代码 · 共 87 行

CS
87
字号
namespace FreeTextBoxControls.Support.Sgml
{
    using System;
    using System.Reflection;

    internal class HWStack
    {
        public HWStack(int growth)
        {
            this.growth = growth;
        }

        public object Pop()
        {
            this.count--;
            if (this.count > 0)
            {
                return this.items[this.count - 1];
            }
            return null;
        }

        public object Push()
        {
            if (this.count == this.size)
            {
                int num1 = this.size + this.growth;
                object[] objArray1 = new object[num1];
                if (this.items != null)
                {
                    Array.Copy(this.items, objArray1, this.size);
                }
                this.size = num1;
                this.items = objArray1;
            }
            return this.items[this.count++];
        }

        public void RemoveAt(int i)
        {
            this.items[i] = null;
            Array.Copy(this.items, i + 1, this.items, i, (this.count - i) - 1);
            this.count--;
        }


        public int Count
        {
            get
            {
                return this.count;
            }
            set
            {
                this.count = value;
            }
        }

        public object this[int i]
        {
            get
            {
                return (((i >= 0) && (i < this.size)) ? this.items[i] : null);
            }
            set
            {
                this.items[i] = value;
            }
        }

        public int Size
        {
            get
            {
                return this.size;
            }
        }


        private int count;
        private int growth;
        private object[] items;
        private int size;
    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?