Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void insert(int keyVal, StringListExt listVal){
- ArrayHeapEntry newEntry = new ArrayHeapEntry(keyVal, listVal);
- heap.add(newEntry);
- int index = heap.size() - 1;
- int child = index;
- int parent = (child - 1) / 2;
- if (heap.size()-1 != 0){
- while (heap.get(parent).getKey() < heap.get(child).getKey()) {
- ArrayHeapEntry temp = heap.get(child);
- heap.set(heap.indexOf(heap.get(child)), heap.get(parent));
- heap.set(heap.indexOf(heap.get(parent)), temp);
- child = parent;
- parent = (child - 1) / 2;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement