コード例 #1
0
ファイル: DankList.cs プロジェクト: antonAce/net-core-tasks
        public void RemoveAt(int index)
        {
            if (index == 0)
            {
                core = core.Next;
            }
            else
            {
                if (index >= this.Count)
                {
                    throw new IndexOutOfRangeException();
                }

                ListComponent <T> pointer = core;

                for (int i = 0; i < index - 1; i++)
                {
                    if (pointer is NullElement <T> )
                    {
                        throw new IndexOutOfRangeException();
                    }

                    pointer = pointer.Next;
                }

                ListComponent <T> afterCompontent = pointer.Next.Next;
                pointer.PushNext(afterCompontent);
            }
        }
コード例 #2
0
ファイル: DankList.cs プロジェクト: antonAce/net-core-tasks
        public override void PushEnd(ListComponent <T> component)
        {
            ListComponent <T> pointer = this;

            while (!(pointer.Next is NullElement <T>))
            {
                pointer = pointer.Next;
            }

            pointer.PushNext(component);
        }
コード例 #3
0
ファイル: DankList.cs プロジェクト: antonAce/net-core-tasks
        public void Insert(int index, T item)
        {
            ListComponent <T> pointer = core;

            for (int i = 0; i < index; i++)
            {
                if (pointer is NullElement <T> )
                {
                    throw new IndexOutOfRangeException();
                }

                pointer = pointer.Next;
            }

            ListComponent <T> afterCompontent  = pointer.Next;
            ListComponent <T> intermediateComp = new ListComposite <T>()
            {
                Value = item
            };

            intermediateComp.PushNext(afterCompontent);
            pointer.PushNext(intermediateComp);
        }