Skip to content

Commit 89f0caa

Browse files
author
AndreyGeonya
committed
quickfind jsdoc
1 parent a0fc935 commit 89f0caa

2 files changed

Lines changed: 35 additions & 22 deletions

File tree

‎doc-config.json‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
"./src/combinatorics/",
1313
"./src/primes/",
1414
"./src/others/",
15-
"./src/searching/"
15+
"./src/searching/",
16+
"./src/sets/"
1617
],
1718
"includePattern": ".+\\.js(doc)?$",
1819
"excludePattern": "docs"

‎src/sets/quickfind.js‎

Lines changed: 33 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,33 @@
1+
/**
2+
* Keeps track of a set of elements partitioned into a
3+
* number of disjoint (nonoverlapping) subsets.
4+
*
5+
* @example
6+
*
7+
* var QuickFind = require('path-to-algorithms/src/sets/quickfind').QuickFind;
8+
*
9+
* var find = new QuickFind(10);
10+
* find.union(0, 1);
11+
* find.union(2, 1);
12+
* find.union(3, 4);
13+
* find.union(8, 9);
14+
* find.union(4, 8);
15+
*
16+
* console.log(find.connected(0, 9)); // false
17+
* console.log(find.connected(3, 9)); // true
18+
*
19+
* @public
20+
* @module sets/quickfind
21+
*/
122
(function (exports) {
223
'use strict';
324

425
/**
5-
* Checks whether there is a path between two nodes.
6-
* The initialization is O(n).
26+
* Initialization.<br><br>
27+
* Complexity: O(N).
728
*
829
* @constructor
9-
* @param {numner} size The count of the nodes
30+
* @param {Numner} size Count of the nodes.
1031
*/
1132
function QuickFind(size) {
1233
this._ids = [];
@@ -16,11 +37,11 @@
1637
}
1738

1839
/**
19-
* Connects two nodes - p and q.
20-
* Complexity O(n).
40+
* Connects two nodes - p and q.<br><br>
41+
* Complexity: O(N).
2142
*
22-
* @param {number} p The first node
23-
* @param {number} q The second node
43+
* @param {Number} p The first node.
44+
* @param {Number} q The second node.
2445
*/
2546
QuickFind.prototype.union = function (p, q) {
2647
var size = this._ids.length;
@@ -34,11 +55,11 @@
3455
};
3556

3657
/**
37-
* Checks whether two nodes are connected.
38-
* Complexity O(1).
58+
* Checks whether two nodes are connected.<br><br>
59+
* Complexity: O(1).
3960
*
40-
* @param {number} p The first node
41-
* @param {number} q The second node
61+
* @param {number} p The first node.
62+
* @param {number} q The second node.
4263
*
4364
*/
4465
QuickFind.prototype.connected = function (p, q) {
@@ -47,13 +68,4 @@
4768

4869
exports.QuickFind = QuickFind;
4970

50-
//var find = new QuickFind(10);
51-
//find.union(0, 1);
52-
//find.union(2, 1);
53-
//find.union(3, 4);
54-
//find.union(8, 9);
55-
//find.union(4, 8);
56-
//
57-
//console.log(find.connected(0, 9)); //expected false
58-
//console.log(find.connected(3, 9)); //expected true
59-
}(typeof exports === 'undefined' ? window : exports));
71+
})(typeof window === 'undefined' ? module.exports : window);

0 commit comments

Comments
 (0)