-
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
1447156
commit 6d0d15e
Showing
20 changed files
with
521 additions
and
463 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,30 @@ | ||
var domReady = function(callback) { | ||
var state = document.readyState ; | ||
if ( state === 'interactive' || state === 'complete' ) { | ||
callback() ; | ||
} | ||
else { | ||
const domReady = function (callback) { | ||
const state = document.readyState; | ||
if (state === 'interactive' || state === 'complete') { | ||
callback(); | ||
} else { | ||
document.addEventListener('DOMContentLoaded', callback); | ||
} | ||
} ; | ||
|
||
}; | ||
|
||
domReady(function(){ | ||
|
||
var projectname = document.createElement('a'); | ||
domReady(function () { | ||
const projectname = document.createElement('a'); | ||
projectname.classList.add('project-name'); | ||
projectname.text = 'union-find/contiguous'; | ||
projectname.href = './index.html' ; | ||
projectname.href = './index.html'; | ||
|
||
var header = document.getElementsByTagName('header')[0] ; | ||
header.insertBefore(projectname,header.firstChild); | ||
const header = document.querySelectorAll('header')[0]; | ||
header.insertBefore(projectname, header.firstChild); | ||
|
||
var testlink = document.querySelector('header > a[data-ice="testLink"]') ; | ||
testlink.href = 'https://coveralls.io/github/union-find/contiguous' ; | ||
testlink.target = '_BLANK' ; | ||
const testlink = document.querySelector('header > a[data-ice="testLink"]'); | ||
testlink.href = 'https://coveralls.io/github/union-find/contiguous'; | ||
testlink.target = '_BLANK'; | ||
|
||
var searchBox = document.querySelector('.search-box'); | ||
var input = document.querySelector('.search-input'); | ||
const searchBox = document.querySelector('.search-box'); | ||
const input = document.querySelector('.search-input'); | ||
|
||
// active search box when focus on searchBox. | ||
input.addEventListener('focus', function(){ | ||
// Active search box when focus on searchBox. | ||
input.addEventListener('focus', function () { | ||
searchBox.classList.add('active'); | ||
}); | ||
|
||
}); |
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,35 +1,25 @@ | ||
import { selfs } from '../fundamentals/index.js' ; | ||
import {identity} from '../fundamentals/index.js'; | ||
|
||
export function union ( p , a , b ) { | ||
export const union = (p, a, b) => { | ||
p[find(p, b)] = find(p, a); | ||
|
||
p[ find( p , b ) ] = find( p , a ) ; | ||
return a; | ||
}; | ||
|
||
return a ; | ||
export const find = (p, x) => { | ||
while (x !== p[x]) x = p[x]; | ||
|
||
} | ||
|
||
export function find ( p , x ) { | ||
|
||
while ( x !== p[x] ) x = p[x] ; | ||
|
||
return x ; | ||
return x; | ||
}; | ||
|
||
export function Universe(n, List = Array) { | ||
this.p = identity(n, List); | ||
} | ||
|
||
export function Universe ( n , List = Array ) { | ||
this.p = selfs( n , List ) ; | ||
} | ||
|
||
Universe.prototype.union = function ( a , b ) { | ||
return union( this.p , a , b ) ; | ||
} ; | ||
|
||
Universe.prototype.find = function ( x ) { | ||
return find( this.p , x ) ; | ||
} ; | ||
Universe.prototype.union = function (a, b) { | ||
return union(this.p, a, b); | ||
}; | ||
|
||
export default { | ||
Universe , | ||
union , | ||
find , | ||
} ; | ||
Universe.prototype.find = function (x) { | ||
return find(this.p, x); | ||
}; |
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,26 +1,16 @@ | ||
import { rankedtreeunion , _RankedTreeUniverse } from '../fundamentals/index.js' ; | ||
import {rankedtreeunion, _RankedTreeUniverse} from '../fundamentals/index.js'; | ||
|
||
export const union = rankedtreeunion ; | ||
export const union = rankedtreeunion; | ||
|
||
export function find ( p , node ) { | ||
|
||
let parent = p[node] ; | ||
|
||
for ( ; p[parent] !== parent ; parent = p[node] ) { | ||
|
||
p[node] = p[parent] ; | ||
node = p[node] ; | ||
export const find = (p, node) => { | ||
let parent = p[node]; | ||
|
||
for (; p[parent] !== parent; parent = p[node]) { | ||
p[node] = p[parent]; | ||
node = p[node]; | ||
} | ||
|
||
return parent ; | ||
|
||
} | ||
|
||
export const Universe = _RankedTreeUniverse( union , find ) ; | ||
return parent; | ||
}; | ||
|
||
export default { | ||
Universe , | ||
union , | ||
find , | ||
} ; | ||
export const Universe = _RankedTreeUniverse(union, find); |
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,19 +1,11 @@ | ||
import { rankedtreeunion , _RankedTreeUniverse } from '../fundamentals/index.js' ; | ||
import {rankedtreeunion, _RankedTreeUniverse} from '../fundamentals/index.js'; | ||
|
||
export const union = rankedtreeunion ; | ||
export const union = rankedtreeunion; | ||
|
||
export function find ( p , node ) { | ||
export const find = (p, node) => { | ||
if (node !== p[node]) p[node] = find(p, p[node]); | ||
|
||
if ( node !== p[node] ) p[node] = find( p , p[node] ) ; | ||
return p[node]; | ||
}; | ||
|
||
return p[node] ; | ||
|
||
} | ||
|
||
export const Universe = _RankedTreeUniverse( union , find ) ; | ||
|
||
export default { | ||
Universe , | ||
union , | ||
find , | ||
} ; | ||
export const Universe = _RankedTreeUniverse(union, find); |
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,26 +1,16 @@ | ||
import { rankedtreeunion , _RankedTreeUniverse } from '../fundamentals/index.js' ; | ||
import {rankedtreeunion, _RankedTreeUniverse} from '../fundamentals/index.js'; | ||
|
||
export const union = rankedtreeunion ; | ||
export const union = rankedtreeunion; | ||
|
||
export function find ( p , node ) { | ||
|
||
let parent = p[node] ; | ||
|
||
for ( ; p[parent] !== parent ; parent = p[node] ) { | ||
|
||
p[node] = p[parent] ; | ||
node = parent ; | ||
export const find = (p, node) => { | ||
let parent = p[node]; | ||
|
||
for (; p[parent] !== parent; parent = p[node]) { | ||
p[node] = p[parent]; | ||
node = parent; | ||
} | ||
|
||
return parent ; | ||
|
||
} | ||
|
||
export const Universe = _RankedTreeUniverse( union , find ) ; | ||
return parent; | ||
}; | ||
|
||
export default { | ||
Universe , | ||
union , | ||
find , | ||
} ; | ||
export const Universe = _RankedTreeUniverse(union, find); |
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,29 +1,19 @@ | ||
import { rankedtreeunion , _RankedTreeUniverse } from '../fundamentals/index.js' ; | ||
import {rankedtreeunion, _RankedTreeUniverse} from '../fundamentals/index.js'; | ||
|
||
export const union = rankedtreeunion ; | ||
export const union = rankedtreeunion; | ||
|
||
export function find ( p , node ) { | ||
export const find = (p, node) => { | ||
let it = node; | ||
|
||
let it = node ; | ||
|
||
for ( ; it !== p[it] ; it = p[it] ) ; | ||
|
||
while ( p[node] !== it ) { | ||
|
||
const parent = p[node] ; | ||
p[node] = it ; | ||
node = parent ; | ||
for (; it !== p[it]; it = p[it]); | ||
|
||
while (p[node] !== it) { | ||
const parent = p[node]; | ||
p[node] = it; | ||
node = parent; | ||
} | ||
|
||
return it ; | ||
|
||
} | ||
|
||
export const Universe = _RankedTreeUniverse( union , find ) ; | ||
return it; | ||
}; | ||
|
||
export default { | ||
Universe , | ||
union , | ||
find , | ||
} ; | ||
export const Universe = _RankedTreeUniverse(union, find); |
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,36 +1,26 @@ | ||
import { selfs , nulls } from '../fundamentals/index.js' ; | ||
import {identity, nulls} from '../fundamentals/index.js'; | ||
|
||
export function union ( back , next , a , b ) { | ||
export const union = (back, next, a, b) => { | ||
next[back[a]] = b; | ||
back[a] = back[b]; | ||
return a; | ||
}; | ||
|
||
next[back[a]] = b ; | ||
back[a] = back[b] ; | ||
return a ; | ||
export const find = (next, node) => { | ||
while (next[node] !== -1) node = next[node]; | ||
|
||
} | ||
|
||
export function find ( next , node ) { | ||
|
||
while ( next[node] !== -1 ) node = next[node] ; | ||
|
||
return node ; | ||
return node; | ||
}; | ||
|
||
export function Universe(n, List = Array) { | ||
this.back = identity(n, List); | ||
this.next = nulls(n, List); | ||
} | ||
|
||
export function Universe ( n , List = Array ) { | ||
this.back = selfs( n , List ) ; | ||
this.next = nulls( n , List ) ; | ||
} | ||
|
||
Universe.prototype.union = function ( a , b ) { | ||
return union( this.back , this.next , a , b ) ; | ||
} ; | ||
|
||
Universe.prototype.find = function ( node ) { | ||
return find( this.next , node ) ; | ||
} ; | ||
Universe.prototype.union = function (a, b) { | ||
return union(this.back, this.next, a, b); | ||
}; | ||
|
||
export default { | ||
Universe , | ||
union , | ||
find , | ||
} ; | ||
Universe.prototype.find = function (node) { | ||
return find(this.next, node); | ||
}; |
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,33 +1,25 @@ | ||
import { selfs , nulls } from '../fundamentals/index.js' ; | ||
import {identity, nulls} from '../fundamentals/index.js'; | ||
|
||
export function union ( back , next , a , b ) { | ||
export const union = (back, next, a, b) => { | ||
next[back[a]] = b; | ||
back[a] = back[b]; | ||
|
||
next[back[a]] = b ; | ||
back[a] = back[b] ; | ||
for (let c = next[a]; c !== b; c = next[c]) back[c] = back[b]; | ||
|
||
for ( let c = next[a] ; c !== b ; c = next[c] ) back[c] = back[b] ; | ||
return a; | ||
}; | ||
|
||
return a ; | ||
export const find = (back, node) => back[node]; | ||
|
||
export function Universe(n, List = Array) { | ||
this.back = identity(n, List); | ||
this.next = nulls(n, List); | ||
} | ||
|
||
export const find = ( back , node ) => back[node] ; | ||
Universe.prototype.union = function (a, b) { | ||
return union(this.back, this.next, a, b); | ||
}; | ||
|
||
export function Universe ( n , List = Array) { | ||
this.back = selfs( n , List ) ; | ||
this.next = nulls( n , List ) ; | ||
} | ||
|
||
Universe.prototype.union = function ( a , b ) { | ||
return union( this.back , this.next , a , b ) ; | ||
} ; | ||
|
||
Universe.prototype.find = function ( node ) { | ||
return find( this.back , node ) ; | ||
} ; | ||
|
||
export default { | ||
Universe , | ||
union , | ||
find , | ||
} ; | ||
Universe.prototype.find = function (node) { | ||
return find(this.back, node); | ||
}; |
Oops, something went wrong.