/// <summary> /// Merge other <see cref="Treap{T} "/> into current one and clear other treap. /// </summary> /// <param name="other">Treap to be merged in.</param> /// <remarks> This method is O(Mlog(N/M)) operation.</remarks> public void MergeIn(Treap <T> other) { if (other.Count == 0) { return; } _version++; _root = Unite(_root, other._root); other.Clear(); }
/// <summary> /// Initializes a new instance of the <see cref="Enumerator"/> struct. /// </summary> /// <param name="treap">Treap to iterate.</param> /// <param name="reverse">Should be in reverse order or not.</param> internal Enumerator(Treap <T> treap, bool reverse = false) { _treap = treap; _version = treap._version; // log(n) is the average height of heap. _stack = new Stack <Node>(Utils.Log2(treap.Count)); _current = null; _reverse = reverse; Initialize(); }