/// <summary> /// Initializes a new instance of the <see cref="SortedList<T>"/> 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); } }
/// <summary> /// Initializes a new instance of the <see cref="Heap<T>" /> 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); }
/// <summary> /// Initializes a new instance of the <see cref="GeneralTree<T>" /> class. /// </summary> /// <param name="data"> The data held in this tree. </param> public GeneralTree(T data) { ChildNodes = new VisitableList <GeneralTree <T> >(); Data = data; }
/// <summary> /// Initializes a new instance of the <see cref="SortedList<T>"/> 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; }
/// <summary> /// Initializes a new instance of the <see cref="SortedList<T>"/> 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; }
/// <summary> /// Initializes a new instance of the <see cref="SortedList<T>"/> class. /// </summary> /// <param name="comparer">The comparer to use.</param> public SortedList(IComparer <T> comparer) { _data = new VisitableList <T>(); _comparerToUse = comparer; }
/// <summary> /// Initializes a new instance of the <see cref="SortedList<T>"/> class. /// </summary> public SortedList() { _data = new VisitableList <T>(); _comparerToUse = Comparer <T> .Default; }