# pheapjs **Repository Path**: xiajxiaj/pheapjs ## Basic Information - **Project Name**: pheapjs - **Description**: js 实现的堆(优先队列)数据结构 - **Primary Language**: JavaScript - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2022-07-23 - **Last Updated**: 2022-07-31 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README ```javascript const { Heap } = require('pheapjs'); const h = new Heap((a, b) => a - b); // the compareFunc can passed by Heap constructor as argument as the pre line or as below // h.compareFunc = (a, b) => a - b; // offer datas h.offer(2); h.offer(6); h.offer(1); h.offer(5); h.offer(7); h.offer(8); h.offer(9); h.offer(3); h.offer(3); // h.setCompareFunc((a, b) => b -a); // console.log(h._datas) // console.log(h.peek()); // pull datas while (h.size() > 0) { console.log(h.pull()); } /* output is: 1 2 3 3 5 6 7 8 9 */ ```