MCPcopy Create free account
hub / github.com/BaseXdb/basex / insert

Method insert

basex-core/src/main/java/org/basex/util/MinHeap.java:34–47  ·  view source on GitHub ↗

Inserts the given key/value pair into the heap. @param key key @param value value

(final K key, final V value)

Source from the content-addressed store, hash-verified

32 * @param value value
33 */
34 public void insert(final K key, final V value) {
35 final int s = size << 1;
36 if(s == vals.length) vals = Array.copy(vals, new Object[s << 1]);
37 vals[s] = key;
38 vals[s + 1] = value;
39
40 // let the inserted value bubble up to its position
41 int curr = size++, par = (curr - 1) / 2;
42 while(curr > 0 && compare(curr, par) < 0) {
43 swap(curr, par);
44 curr = par;
45 par = (curr - 1) / 2;
46 }
47 }
48
49 /**
50 * Removes the minimum from this heap.

Callers 4

heapSortMethod · 0.95
heapPreSortMethod · 0.95
valueMethod · 0.95
valueMethod · 0.95

Calls 3

copyMethod · 0.95
compareMethod · 0.95
swapMethod · 0.95

Tested by 2

heapSortMethod · 0.76
heapPreSortMethod · 0.76