* Initializes an empty B+ tree. * @param compare Custom function to compare pairs of elements in the tree. * If not specified, defaultComparator will be used which is valid as long as K extends DefaultComparable. * @param entries A set of key-value pairs to initialize the tree * @param
(
compare: (a: K, b: K) => number,
entries?: Array<[K, V]>,
maxNodeSize?: number,
)
| 115 | * Must be in range 4..256. If undefined or <4 then default is used; if >256 then 256. |
| 116 | */ |
| 117 | public constructor( |
| 118 | compare: (a: K, b: K) => number, |
| 119 | entries?: Array<[K, V]>, |
| 120 | maxNodeSize?: number, |
| 121 | ) { |
| 122 | this._maxNodeSize = maxNodeSize! >= 4 ? Math.min(maxNodeSize!, 256) : 32 |
| 123 | this._compare = compare |
| 124 | if (entries) this.setPairs(entries) |
| 125 | } |
| 126 | |
| 127 | // /////////////////////////////////////////////////////////////////////////// |
| 128 | // ES6 Map<K,V> methods ///////////////////////////////////////////////////// |