Exemple #1
0
        public void RemoveAt(int index)
        {
            if (index > this.Count)
            {
                throw new InvalidOperationException("Insufficient elements");
            }

            ListEntry <T> current = _head;

            if (index == 0)
            {
                _head = _head.Tail;
                _count--;
            }

            ListEntry <T> previous = null;

            for (int count = 0; count < index; count++)
            {
                previous = current;
                current  = current.Tail;
            }

            previous.Extend(current.Tail);
            _count--;
        }
Exemple #2
0
        public void Add(T item)
        {
            var listEntry = new ListEntry <T>(item);

            listEntry.Extend(_head);
            _head = listEntry;
            _count++;
        }