Пример #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SortedList&lt;T&gt;"/> class.
        /// </summary>
        /// <param name="collection">The collection to copy into the sorted list.</param>
        public SortedList(IEnumerable <T> collection)
        {
            _data = new VisitableList <T>();

            var enumerator = collection.GetEnumerator();

            while (enumerator.MoveNext())
            {
                Add(enumerator.Current);
            }
        }
Пример #2
0
 /// <summary>
 ///   Initializes a new instance of the <see cref="Heap&lt;T&gt;" /> class.
 /// </summary>
 /// <param name="type"> The type of heap. </param>
 /// <param name="comparer"> The comparer to use. </param>
 public Heap(HeapType type, IComparer <T> comparer)
 {
     if (comparer == null)
     {
         throw new ArgumentNullException("comparer");
     }
     Type = type;
     List = new VisitableList <T> {
         default(T)
     };
     Comparer = (type == HeapType.MinHeap) ? comparer : new InvertedComparer <T>(comparer);
 }
Пример #3
0
 /// <summary>
 ///   Initializes a new instance of the <see cref="GeneralTree&lt;T&gt;" /> class.
 /// </summary>
 /// <param name="data"> The data held in this tree. </param>
 public GeneralTree(T data)
 {
     ChildNodes = new VisitableList <GeneralTree <T> >();
     Data       = data;
 }
Пример #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SortedList&lt;T&gt;"/> class.
 /// </summary>
 /// <param name="capacity">The intial capacity of the sorted list.</param>
 /// <param name="comparer">The comparer to use.</param>
 public SortedList(int capacity, IComparer <T> comparer)
 {
     _data          = new VisitableList <T>(capacity);
     _comparerToUse = comparer;
 }
Пример #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SortedList&lt;T&gt;"/> class.
 /// </summary>
 /// <param name="capacity">The intial capacity of the sorted list.</param>
 public SortedList(int capacity)
 {
     _data          = new VisitableList <T>(capacity);
     _comparerToUse = Comparer <T> .Default;
 }
Пример #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SortedList&lt;T&gt;"/> class.
 /// </summary>
 /// <param name="comparer">The comparer to use.</param>
 public SortedList(IComparer <T> comparer)
 {
     _data          = new VisitableList <T>();
     _comparerToUse = comparer;
 }
Пример #7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SortedList&lt;T&gt;"/> class.
 /// </summary>
 public SortedList()
 {
     _data          = new VisitableList <T>();
     _comparerToUse = Comparer <T> .Default;
 }