Esempio n. 1
0
        /// <summary>
        /// Removes the item at the specified index.
        /// </summary>
        ///
        /// <exception cref="IndexOutOfRangeException">
        /// Thrown when the index is outside the bound of the current set.
        /// </exception>
        ///
        /// <param name="index">
        /// Zero-based index of the item to remove.
        /// </param>

        public void RemoveAt(int index)
        {
            if (index >= Count || Count == 0)
            {
                throw new IndexOutOfRangeException("Index out of range");
            }

            T item = OrderedList.ElementAt(index);

            MutableList.Remove(item);
            MutableListOrdered.Remove(item);
            Touch();
        }
Esempio n. 2
0
        /// <summary>
        /// Indexer to get or set items within this collection using array index syntax.
        /// </summary>
        ///
        /// <param name="index">
        /// Zero-based index of the entry to access.
        /// </param>
        ///
        /// <returns>
        /// The indexed item.
        /// </returns>

        public T this[int index]
        {
            get
            {
                return(OrderedList.ElementAt(index));
            }
            set
            {
                T item = OrderedList.ElementAt(index);

                MutableList.Remove(item);
                MutableList.Add(value);

                int i = MutableListOrdered.IndexOf(item);

                MutableListOrdered[i] = value;
                Touch();
            }
        }