コード例 #1
0
        private void TraverseInOrder <T>(Predicate <T> action, ICollection <T> list)
        {
            InOrderFlatEnumerator <TKey, TValue>       enumerator  = new InOrderFlatEnumerator <TKey, TValue>(this);
            ICollection <KeyValuePair <TKey, TValue> > lstIterator = enumerator.Iterator;

            foreach (KeyValuePair <TKey, TValue> entry in lstIterator)
            {
                list.Add(action(entry));
            }
        }
コード例 #2
0
        /// <summary>Copies the Tree elements to a one-dimensional Array instance at the specified index.</summary>
        /// <param name="array">The one dimensional Array to copy the elements to.</param>
        /// <param name="index">The zero-based index in array at which copying begins.</param>
        /// <exception cref="ArgumentNullException">Thrown if array is null.</exception>
        /// <exception cref="ArgumentOutOfRangeException">Thrown if index is less than zero or if index
        /// is greater than the size of array.</exception>
        /// <exception cref="ArgumentException">Thrown if the number of items in the list is greater than the
        /// available space in array.</exception>
        /// <exception cref="InvalidCastException">The type of the source Tree cannot be cast automatically
        /// to the type of the destination array.</exception>
        public void CopyTo(KeyValuePair <TKey, TValue>[] array, int index)
        {
            if (array == null)
            {
                throw new ArgumentNullException("array", "array cannot be null");
            }

            if ((index < 0) || (index >= array.Length))
            {
                throw new ArgumentOutOfRangeException("index", index, "index must be greater than zero and less than the size of array");
            }

            if ((array.Length - index) < Count)
            {
                throw new ArgumentException("array is not large enough to store the list", "array");
            }

            InOrderFlatEnumerator <TKey, TValue> enumerator = new InOrderFlatEnumerator <TKey, TValue>(this);

            enumerator.Iterator.CopyTo(array, index);
        }