示例#1
0
        protected void AppendChild(T child)
        {
            var linkedChild = new LinkedObject <T>(child);

            if (this.LastChild != null)
            {
                linkedChild.Prev    = this.LastChild;
                this.LastChild.Next = linkedChild;
            }

            this.LastChild = linkedChild;

            if (this.FirstChild == null)
            {
                this.FirstChild = this.LastChild;
            }
        }
示例#2
0
        protected void PrependChild(T child) // TODO: Exstract the chain logic to a separate class.
        {
            var linkedChild = new LinkedObject <T>(child);

            if (this.FirstChild != null)
            {
                linkedChild.Next     = this.FirstChild;
                this.FirstChild.Prev = linkedChild;
            }

            this.FirstChild = linkedChild;

            if (this.LastChild == null)
            {
                this.LastChild = this.FirstChild;
            }
        }