/// <summary> /// Return clone of element. /// </summary> /// <returns>Clone of elements.</returns> public object Clone() { HeapWithIndices <TValue> clone = new HeapWithIndices <TValue>(); clone.count = count; clone.elements = new HeapEntry[elements.Length]; clone.head = head; clone.isHeap = isHeap; clone.ListTreshold = ListTreshold; clone.keysPosition = new int[keysPosition.Length]; Array.Copy(keysPosition, clone.keysPosition, keysPosition.Length); Array.Copy(elements, clone.elements, count); clone.comparer = this.comparer; return(clone); }
/// <summary> /// Return clone of element. /// </summary> /// <returns>Clone of elements.</returns> public object Clone() { HeapWithIndices <TValue, TKey> clone = new HeapWithIndices <TValue, TKey>(); clone.count = count; clone.elements = new HeapEntry[elements.Length]; clone.head = head; clone.keysPosition = new int[keysPosition.Length]; clone.isHeap = isHeap; clone.ListTreshold = ListTreshold; Array.Copy(keysPosition, clone.keysPosition, keysPosition.Length); Array.Copy(elements, clone.elements, count); clone.keys = new Dictionary <TKey, int>(); foreach (var item in keys) { clone.keys.Add(item.Key, item.Value); } clone.comparer = this.comparer; return(clone); }
/// <summary> /// Get internal array with heap's entries /// </summary> /// <typeparam name="TValue">TValue</typeparam> /// <param name="heap">Heap</param> /// <returns>Internal array with heap's entries</returns> public static HeapWithIndices <TValue> .HeapEntry[] GetEntries <TValue>(HeapWithIndices <TValue> heap) { return(heap.elements); }
/// <summary> /// Get isHeap field from heap(true if it is real heap, not sorted list). /// </summary> /// <typeparam name="TValue">TValue.</typeparam> /// <typeparam name="TKey">TKey</typeparam> /// <param name="heap">Heap</param> /// <returns>true if it is real heap, not sorted list</returns> public static bool IsHeap <TValue, TKey>(HeapWithIndices <TValue, TKey> heap) { return(heap.isHeap); }
internal HeapWithIndicesEnumerator(HeapWithIndices <TValue, TKey> heap) { this.heap = heap; index = -1; version = heap.version; }