-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from datastructures-js/development
add typescript
- Loading branch information
Showing
13 changed files
with
157 additions
and
169 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
const MinHeap = require('./src/minHeap'); | ||
const MaxHeap = require('./src/maxHeap'); | ||
const { MinHeap } = require('./src/minHeap'); | ||
const { MaxHeap } = require('./src/maxHeap'); | ||
|
||
exports.MinHeap = MinHeap; | ||
exports.MaxHeap = MaxHeap; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
export interface HeapNode<T extends number|string, U> { | ||
key: T; | ||
value: U; | ||
} | ||
|
||
export abstract class Heap<T extends number|string, U = undefined> { | ||
constructor(elements?: (HeapNode<T, U> | T)[], leaf?: (HeapNode<T, U> | T)); | ||
extractRoot(): HeapNode<T, U> | T; | ||
insert(key: T, value?: U): Heap<T, U>; | ||
sort(): (HeapNode<T, U> | T)[]; | ||
fix(): void; | ||
isValid(): boolean; | ||
root(): HeapNode<T, U> | T; | ||
leaf(): HeapNode<T, U> | T; | ||
size(): number; | ||
isEmpty(): boolean; | ||
clear(): void; | ||
} |
Oops, something went wrong.