Ejemplo n.º 1
0
        public override void InsertPos(int position, Koltuk value)
        {
            if (position < 0 || position + 1 > this.Size)
            {
                throw new IndexOutOfRangeException();
            }
            else if (position == 0 || this.Head == null)
            {
                this.InsertFirst(value);
            }
            else
            {
                Node newNode = new Node()
                {
                    Data = value
                };

                Node currentNode      = this.Head;
                Node lastPreviousNode = this.Head;
                for (int counter = 0; counter < position; counter++)
                {
                    lastPreviousNode = currentNode;
                    currentNode      = currentNode.Next;
                }

                newNode.Next          = currentNode;
                lastPreviousNode.Next = newNode;
                this.Size++;
            }
        }
Ejemplo n.º 2
0
        public override void InsertFirst(Koltuk value)
        {
            Node newHead = new Node()
            {
                Data = value
            };
            Node tmpHead = this.Head;

            newHead.Next = this.Head;
            this.Head    = newHead;
            this.Size++;
        }
Ejemplo n.º 3
0
        public override void InsertLast(Koltuk value)
        {
            if (this.Head == null)
            {
                this.InsertFirst(value);
            }
            else
            {
                Node newLast = new Node()
                {
                    Data = value
                };
                Node currentNode = this.Head;
                while (currentNode.Next != null)
                {
                    currentNode = currentNode.Next;
                }

                currentNode.Next = newLast;
                Size++;
            }
        }
Ejemplo n.º 4
0
 public abstract void InsertPos(int position, Koltuk value);
Ejemplo n.º 5
0
 public abstract void InsertLast(Koltuk value);