-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9da7d4a
commit 9ed6468
Showing
6 changed files
with
81 additions
and
162 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,42 @@ | ||
# Examples | ||
|
||
> More examples in [the test files](https://github.com/{repository}/tree/master/test/src). | ||
> More examples in [the test files](https://github.com/aureooms/js-mergesort/tree/master/test/src). | ||
|
||
```js | ||
let array = require( "@aureooms/js-array" ) ; | ||
let compare = require( "@aureooms/js-compare" ) ; | ||
let merging = require( "@aureooms/js-merging" ) ; | ||
|
||
/** recursive mergesort */ | ||
let sort = mergesort.recursive( merging.tapemerge , array.copy ) ; | ||
|
||
/** iterative mergesort */ | ||
let sort = mergesort.iterative( merging.tapemerge , array.copy ) ; | ||
|
||
// for example | ||
|
||
let random = require( "@aureooms/js-random" ) ; | ||
|
||
let n = 10 ; | ||
let A = array.alloc( n ) ; | ||
let B = array.alloc( n ) ; | ||
|
||
array.iota( A , 0 , n , 0 ) ; | ||
|
||
A ; // [ 0 , 1 , ... , 9 ] | ||
|
||
random.shuffle( A , 0 , n ) ; | ||
|
||
sort( compare.increasing , A , 0 , n , B , 0 , n ) ; | ||
|
||
B ; // [ 0 , 1 , ... , 9 ] | ||
|
||
// or decreasing | ||
|
||
random.shuffle( A , 0 , n ) ; | ||
|
||
sort( compare.decreasing , A , 0 , n , B , 0 , n ) ; | ||
|
||
B ; // [ 9 , 8 , ... , 0 ] | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,34 @@ | ||
var domReady = function(callback) {{ | ||
var domReady = function(callback) { | ||
var state = document.readyState ; | ||
if ( state === 'interactive' || state === 'complete' ) {{ | ||
if ( state === 'interactive' || state === 'complete' ) { | ||
callback() ; | ||
}} | ||
else {{ | ||
} | ||
else { | ||
document.addEventListener('DOMContentLoaded', callback); | ||
}} | ||
}} ; | ||
} | ||
} ; | ||
|
||
|
||
domReady(function(){{ | ||
domReady(function(){ | ||
|
||
var projectname = document.createElement('a'); | ||
projectname.classList.add('project-name'); | ||
projectname.text = '{repository}'; | ||
projectname.text = 'aureooms/js-mergesort'; | ||
projectname.href = './index.html' ; | ||
|
||
var header = document.getElementsByTagName('header')[0] ; | ||
header.insertBefore(projectname,header.firstChild); | ||
|
||
var testlink = document.querySelector('header > a[data-ice="testLink"]') ; | ||
testlink.href = 'https://coveralls.io/github/{repository}' ; | ||
testlink.href = 'https://coveralls.io/github/aureooms/js-mergesort' ; | ||
testlink.target = '_BLANK' ; | ||
|
||
var searchBox = document.querySelector('.search-box'); | ||
var input = document.querySelector('.search-input'); | ||
|
||
// active search box when focus on searchBox. | ||
input.addEventListener('focus', function(){{ | ||
input.addEventListener('focus', function(){ | ||
searchBox.classList.add('active'); | ||
}}); | ||
}); | ||
|
||
}}); | ||
}); |