Mergesort module
- Source:
(require("Mergesort"))(config) → {module:Mergesort~instance}
Returns a Mergesort
instance
let instance = Mergesort(); //switches to insertion sort for array fragments < 16
instance = Mergesort({threshold: 64}); //will switch to insertion sort for fragments < 64
instance = Mergesort({size:999}); //will throw an error if you try to sort arrays with length other than 999
Parameters:
Name | Type | Description |
---|---|---|
config |
module:Mergesort~config | a configuration object with optional parameters (default 16) |
- Source:
Returns:
Namespaces
Type Definitions
config
An optinal configuration object that can be passed to the Mergesort
factory function
Type:
- Object
Properties:
Name | Type | Description |
---|---|---|
threshold |
number | The threshold below where the algorithm temporarily switches over to insertion sort |
size |
number | Use this if you are going to consistently sort arrays of fixed size.
Refers to size of the array to be sorted, where a binary tree is precalculated.
The tree will be reused for each call of the returned |
- Source: