Skip to content

Commit

Permalink
refactor(heaps): add Iterable, IClear decls
Browse files Browse the repository at this point in the history
  • Loading branch information
postspectacular committed Dec 29, 2019
1 parent 7015512 commit dbf488b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
9 changes: 8 additions & 1 deletion packages/heaps/src/heap.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {
Comparator,
IClear,
ICopy,
IEmpty,
ILength,
Expand All @@ -26,7 +27,13 @@ import { HeapOpts } from "./api";
* ```
*/
export class Heap<T>
implements ICopy<Heap<T>>, IEmpty<Heap<T>>, ILength, IStack<T, T, Heap<T>> {
implements
Iterable<T>,
IClear,
ICopy<Heap<T>>,
IEmpty<Heap<T>>,
ILength,
IStack<T, T, Heap<T>> {
static parentIndex(idx: number) {
return idx > 0 ? (idx - 1) >> 1 : -1;
}
Expand Down
3 changes: 3 additions & 0 deletions packages/heaps/src/pairing.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {
Comparator,
Fn,
IClear,
ICopy,
IEmpty,
ILength,
Expand All @@ -17,6 +18,8 @@ interface Node<T> {

export class PairingHeap<T>
implements
Iterable<T>,
IClear,
ICopy<PairingHeap<T>>,
IEmpty<PairingHeap<T>>,
ILength,
Expand Down

0 comments on commit dbf488b

Please sign in to comment.