update README, heap ADT

This commit is contained in:
Mark Thom
2017-12-10 13:55:49 -07:00
parent 9d944e2268
commit 2dc7832f59
2 changed files with 23 additions and 11 deletions

View File

@@ -968,19 +968,13 @@ impl Heap {
}
pub fn push(&mut self, val: HeapCellValue) {
let h = self.h;
if h < self.heap.len() {
self.heap[h] = val;
} else {
self.heap.push(val);
}
self.heap.push(val);
self.h += 1;
}
pub fn truncate(&mut self, h: usize) {
self.h = h;
self.heap.truncate(h);
}
pub fn len(&self) -> usize {
@@ -988,9 +982,10 @@ impl Heap {
}
pub fn append(&mut self, vals: Vec<HeapCellValue>) {
for val in vals.into_iter() {
self.push(val);
}
let n = vals.len();
self.heap.extend(vals.into_iter());
self.h += n;
}
pub fn clear(&mut self) {