Heapifies a node.

@private
@param {BinaryHeap} heap The heap containing the node to heapify.
@param {number} i The index of the node to heapify.
775481
function heapify(heap, i) {
  var l = getLeft(i);
  var r = getRight(i);
  var smallest = i;
  if (l < heap.list.length &&
      heap.compare(heap.list[l], heap.list[i]) < 0) {
    smallest = l;
  }
  if (r < heap.list.length &&
      heap.compare(heap.list[r], heap.list[smallest]) < 0) {
    smallest = r;
  }
  if (smallest !== i) {
    swap(heap.list, i, smallest);
    heapify(heap, smallest);
  }
}
1238106
private void moveElements(int i)
    {
        if (i >= size)
            return;

        System.arraycopy(starts, i, starts, i+1, size - i);
        System.arraycopy(ends, i, ends, i+1, size - i);
        System.arraycopy(markedAts, i, markedAts, i+1, size - i);
        System.arraycopy(delTimes, i, delTimes, i+1, size - i);
        // we set starts[i] to null to indicate the position is now empty, so that we update boundaryHeapSize
        // when we set it
        starts[i] = null;
    }
1363754
private void put(final Item i) {
        if (index > threshold) {
            int ll = items.length;
            int nl = ll * 2 + 1;
            Item[] newItems = new Item[nl];
            for (int l = ll - 1; l >= 0; --l) {
                Item j = items[l];
                while (j != null) {
                    int index = j.hashCode % newItems.length;
                    Item k = j.next;
                    j.next = newItems[index];
                    newItems[index] = j;
                    j = k;
                }
            }
            items = newItems;
            threshold = (int) (nl * 0.75);
        }
        int index = i.hashCode % items.length;
        i.next = items[index];
        items[index] = i;
    }
915525
def _heapify_max(x):
    """"""
    n = len(x)
    for i in reversed(range(n//2)):
        _siftup_max(x, i)
451937
public final T add(T element) {
    size++;
    heap[size] = element;
    upHeap();
    return heap[1];
  }
798945
function discardElement(element) {
	// create a garbage bin element, not part of the DOM
	if (!garbageBin) {
		garbageBin = createElement(DIV);
	}

	// move the node and empty bin
	if (element) {
		garbageBin.appendChild(element);
	}
	garbageBin.innerHTML = '';
}
739463
function(obj, node) {
        var children = node.childNodes;
        var childNode, processor, prefix, local;
        for(var i=0, len=children.length; i<len; ++i) {
            childNode = children[i];
            if(childNode.nodeType == 1) {
                prefix = this.getNamespacePrefix(childNode.namespaceURI);
                local = childNode.nodeName.split(":").pop();
                processor = this["read_" + prefix + "_" + local];
                if(processor) {
                    processor.apply(this, [obj, childNode]);
                }
            }
        }
    }
1048384
def heappush(heap, item):
    """"""
    heap.append(item)
    _siftdown(heap, 0, len(heap)-1)
228784
protected void convertToPointerRepresentation(ArrayDBIDs ids, DoubleLongHeap heap, WritableDBIDDataStore pi, WritableDoubleDataStore lambda) {
    final Logging LOG = getLogger();
    // Initialize parent array:
    for(DBIDArrayIter iter = ids.iter(); iter.valid(); iter.advance()) {
      pi.put(iter, iter); // Initialize
    }
    DBIDVar p = DBIDUtil.newVar(), q = DBIDUtil.newVar(), n = DBIDUtil.newVar();
    FiniteProgress pprog = LOG.isVerbose() ? new FiniteProgress("Converting MST to pointer representation", heap.size(), LOG) : null;
    while(!heap.isEmpty()) {
      final double dist = heap.peekKey();
      final long pair = heap.peekValue();
      final int i = (int) (pair >>> 31), j = (int) (pair & 0x7FFFFFFFL);
      ids.assignVar(i, p);
      // Follow p to its parent.
      while(!DBIDUtil.equal(p, pi.assignVar(p, n))) {
        p.set(n);
      }
      // Follow q to its parent.
      ids.assignVar(j, q);
      while(!DBIDUtil.equal(q, pi.assignVar(q, n))) {
        q.set(n);
      }
      // By definition of the pointer representation, the largest element in
      // each cluster is the cluster lead.
      // The extraction methods currently rely on this!
      int c = DBIDUtil.compare(p, q);
      if(c < 0) {
        // p joins q:
        pi.put(p, q);
        lambda.put(p, dist);
      }
      else {
        assert (c != 0) : "This should never happen!";
        // q joins p:
        pi.put(q, p);
        lambda.put(q, dist);
      }

      heap.poll();
      LOG.incrementProcessed(pprog);
    }
    LOG.ensureCompleted(pprog);
    // Hack to ensure a valid pointer representation:
    // If distances are tied, the heap may return edges such that the n-way join
    // does not fulfill the property that the last element has the largest id.
    for(DBIDArrayIter iter = ids.iter(); iter.valid(); iter.advance()) {
      double d = lambda.doubleValue(iter);
      // Parent:
      pi.assignVar(iter, p);
      q.set(p);
      // Follow parent while tied.
      while(d >= lambda.doubleValue(q) && !DBIDUtil.equal(q, pi.assignVar(q, n))) {
        q.set(n);
      }
      if(!DBIDUtil.equal(p, q)) {
        if(LOG.isDebuggingFinest()) {
          LOG.finest("Correcting parent: " + p + " -> " + q);
        }
        pi.put(iter, q);
      }
    }
  }
134164
function(data){
  this.head;
  this.tail;
  this.size;
  if(typeof data !== 'undefined'){
    this.head = new Node(data);
    this.tail = this.head;
    this.size = 1;
  }else{
    this.head = null;
    this.tail = null;
    this.size = 0;
  }
}
993117
function( root ) { //jshint ignore:line
        for ( var i = 0; i < preInitPlugins.length; i++ ) {
            var thisLevel = preInitPlugins[ i ];
            if ( thisLevel !== undefined ) {
                for ( var j = 0; j < thisLevel.length; j++ ) {
                    thisLevel[ j ]( root );
                }
            }
        }
    }
908183
function(i) {
      
      var itemValue = this.items[i];
   
      this.ul.removeChild(this.ul.childNodes[i]);
      
      this.items[i] = null;
      this.items = inputEx.compactArray(this.items);
      
      return itemValue;
   }
361128
@SuppressWarnings("unchecked")
  protected final void initialize(int maxSize) {
    size = 0;
    int heapSize = maxSize + 1;
    heap = (T[]) new Object[heapSize];
    this.maxSize = maxSize;
  }
1082094
function(node, handler) {
        if (!this.handler[node]) {
            this.handler[node] = [];
        }
        this.handler[node].push(handler);
    }
1014466
function heapUpdate(i, w) {
    var a = heap[i]
    if(weights[a] === w) {
      return i
    }
    weights[a] = -Infinity
    heapUp(i)
    heapPop()
    weights[a] = w
    heapCount += 1
    return heapUp(heapCount-1)
  }
572596
function Heap(compare) {
  if (!(this instanceof Heap))
    return new Heap(compare);

  this.compare = comparator;
  this.items = [];

  if (compare)
    this.set(compare);
}
356927
public static void makeHeap(Quicksortable q, int size) {
        for (int i = (size-1)/2; i >= 0; i--) {
            heapifyDown(q, i, size);
        }
    }