UNPKG
ts-ds-tool
Version:
latest (0.1.5)
0.1.5
0.1.4
0.1.3
0.1.2
0.1.1
0.1.0
Data structure and algorithm of TypeScript
github.com/HaifengDu/ts-ds-tool
HaifengDu/ts-ds-tool
ts-ds-tool
/
src
/
heap
/
MaxHeap.ts
17 lines
(15 loc)
•
313 B
text/typescript
View Raw
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import
{ Heap } from
"./Heap"
;
/** * 大顶堆 */
export
class
MaxHeap
<
T
>
extends
Heap
<
T
>{
constructor
(
private
key?: keyof T){
super
(); }
protected
compare(a: T, b: T): boolean {
if
(
this
.key){
return
a[
this
.key] >= b[
this
.key]; }
return
a >= b; } }