/** * Inserts <code>o</code> into this collection. */ @Override public boolean add(T o) { int i = heap.size(); // index 1 past the end of the heap heap.setSize(i + 1); percolateUp(i, o); return true; }
/** * Inserts <code>o</code> into this collection. */ @Override public boolean add(T o) { int i = heap.size(); // index 1 past the end of the heap heap.setSize(i+1); percolateUp(i, o); return true; }
/** Inserts <code>o</code> into this collection. */ @Override public boolean add(T o) { int lastIndex = heap.size(); heap.add(o); percolateUp(lastIndex, o); return true; }
/** * Inserts <code>o</code> into this collection. */ @Override public boolean add(T o) { int i = heap.size(); // index 1 past the end of the heap heap.setSize(i+1); percolateUp(i, o); return true; }
/** * Informs the heap that this object's internal key value has been updated, * and that its place in the heap may need to be shifted (up or down). * * @param o */ public void update(T o) { // Since we don't know whether the key value increased or // decreased, we just percolate up followed by percolating down; // one of the two will have no effect. int cur = object_indices.get(o).intValue(); // current index int new_idx = percolateUp(cur, o); percolateDown(new_idx); }
/** * Informs the heap that this object's internal key value has been updated, and that its place in * the heap may need to be shifted (up or down). * * @param o the object whose key value has been updated */ public void update(T o) { // Since we don't know whether the key value increased or // decreased, we just percolate up followed by percolating down; // one of the two will have no effect. int cur = objectIndices.get(o); // current index int newIdx = percolateUp(cur, o); percolateDown(newIdx); }
/** * Informs the heap that this object's internal key value has been * updated, and that its place in the heap may need to be shifted * (up or down). * @param o the object whose key value has been updated */ public void update(T o) { // Since we don't know whether the key value increased or // decreased, we just percolate up followed by percolating down; // one of the two will have no effect. int cur = object_indices.get(o).intValue(); // current index int new_idx = percolateUp(cur, o); percolateDown(new_idx); }
/** * Informs the heap that this object's internal key value has been * updated, and that its place in the heap may need to be shifted * (up or down). * @param o */ public void update(T o) { // Since we don't know whether the key value increased or // decreased, we just percolate up followed by percolating down; // one of the two will have no effect. int cur = object_indices.get(o).intValue(); // current index int new_idx = percolateUp(cur, o); percolateDown(new_idx); }