Home Manual Reference Source

Overview

Installation

Can be managed using jspm or npm.

jspm

jspm install npm:@comparison-sorting/specification

npm

npm install @comparison-sorting/specification --save

Usage

The code needs a ES2015+ polyfill to work, for example regenerator-runtime/runtime.

await import( 'regenerator-runtime/runtime.js' ) ;
// or
import 'regenerator-runtime/runtime.js' ;

Then

const measure = await import( '@comparison-sorting/specification' ) ;
// or
import measure from '@comparison-sorting/specification' ;

Examples

import ava from 'ava' ;

import {sort as insertionSort} from '@comparison-sorting/insertion-sort';
import * as heapSort from '@comparison-sorting/heap-sort' ;
import * as quickSort from '@comparison-sorting/quick-sort' ;
import * as partition from '@comparison-sorting/partition' ;
import * as spec from '@comparison-sorting/specification' ;

spec.test( ava , [
    [ 'insertion-sort', insertionSort ],
    [ 'heap-sort (unary)', heapSort.dary( 1 ) ],
    [ 'heap-sort (binary)', heapSort.dary( 2 ) ],
    [ 'heap-sort (ternary)', heapSort.dary( 3 ) ],
    [ 'heap-sort (4-ary)', heapSort.dary( 4 ) ],
    [ 'heap-sort (5-ary)', heapSort.dary( 5 ) ],
    [ 'quick-sort (hoare)', quickSort.single( partition.hoare ) ],
    [ 'quick-sort (lomuto)', quickSort.single( partition.lomuto ) ],
    [ 'quick-sort [dual-pivot] (yaroslavskiy)', quickSort.dual( partition.yaroslavskiy ) ],
] ) ;