Example #1
0
        /// <summary>
        /// Indexer to access the linked list like an array.
        /// </summary>
        /// <param name="i">Index (zero-based) to access an item in the linked list.
        /// Throws <see cref="System.IndexOutOfRangeException"/> if index is out of
        /// range.</param>
        /// <returns>The value stored at the specified index.</returns>
        public T this[int i]
        {
            get {
                LinkedListItem <T> item = Find(i);

                if (item == null)
                {
                    throw new IndexOutOfRangeException();
                }

                return(Find(i).value);
            }
            set
            {
                LinkedListItem <T> item = Find(i);

                if (item == null)
                {
                    throw new IndexOutOfRangeException();
                }

                item.value = value;
            }
        }