Skip to content

Commit

Permalink
Merge pull request #5 from nickzuber/develop
Browse files Browse the repository at this point in the history
Enhancement - O Shit, Here Come Dat New File Structure
  • Loading branch information
nickzuber authored Sep 17, 2016
2 parents 38a8418 + e7452d3 commit 220c8ee
Show file tree
Hide file tree
Showing 53 changed files with 182 additions and 78 deletions.
2 changes: 1 addition & 1 deletion benchmarks/binaryHeap.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

'use strict';

var Needle = require('../src/needle.js');
var Needle = require('../src');
var winston = require('winston');
winston.log('info', 'running speed tests on binary heap');
var start, end, time, iterations, i;
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/binarySearchTree.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

'use strict';

var Needle = require('../src/needle.js');
var Needle = require('../src');
var winston = require('winston');
winston.log('info', 'running speed tests on binary search tree');
var start, end, time, iterations, i;
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/doublyLinkedList.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

'use strict';

var Needle = require('../src/needle.js');
var Needle = require('../src');
var winston = require('winston');
winston.log('info', 'running speed tests on doubly linked list');
var start, end, time, iterations, i;
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/hashmap.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

'use strict';

var Needle = require('../src/needle.js');
var Needle = require('../src');
var winston = require('winston');
winston.log('info', 'running speed tests on hashmap');
var start, end, time, iterations, i;
Expand Down
40 changes: 40 additions & 0 deletions benchmarks/logs/benchmarks.log
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,43 @@
{"level":"info","message":"Stack.push() 1,000,000 iterations took 0.497 seconds to execute.","timestamp":"2016-05-02T00:15:44.460Z"}
{"level":"info","message":"Stack.peek() 1,000,000 iterations took 0.004 seconds to execute.","timestamp":"2016-05-02T00:15:44.466Z"}
{"level":"info","message":"Stack.pop() 1,000,000 iterations took 0.013 seconds to execute.","timestamp":"2016-05-02T00:15:44.482Z"}
{"level":"info","message":"running speed tests on binary heap","timestamp":"2016-09-17T07:16:19.126Z"}
{"level":"info","message":"running speed tests on binary search tree","timestamp":"2016-09-17T07:16:19.129Z"}
{"level":"info","message":"running speed tests on doubly linked list","timestamp":"2016-09-17T07:16:19.130Z"}
{"level":"info","message":"DoublyLinkedList.insertFront() 30,000 iterations took 0.007 seconds to execute.","timestamp":"2016-09-17T07:16:19.150Z"}
{"level":"info","message":"DoublyLinkedList.insertBack() 30,000 iterations took 0.009 seconds to execute.","timestamp":"2016-09-17T07:16:19.160Z"}
{"level":"info","message":"DoublyLinkedList.insertNth() 30,000 iterations took 1.806 seconds to execute.","timestamp":"2016-09-17T07:16:20.966Z"}
{"level":"info","message":"DoublyLinkedList.remove() 30,000 iterations took 0.029 seconds to execute.","timestamp":"2016-09-17T07:16:20.995Z"}
{"level":"info","message":"DoublyLinkedList.insertAfter() 30,000 iterations took 0.027 seconds to execute.","timestamp":"2016-09-17T07:16:21.022Z"}
{"level":"info","message":"DoublyLinkedList.find() 30,000 iterations took 0.015 seconds to execute.","timestamp":"2016-09-17T07:16:21.038Z"}
{"level":"info","message":"DoublyLinkedList.findNth() 30,000 iterations took 0 seconds to execute.","timestamp":"2016-09-17T07:16:21.038Z"}
{"level":"info","message":"DoublyLinkedList.removeNth() 30,000 iterations took 1.135 seconds to execute.","timestamp":"2016-09-17T07:16:22.173Z"}
{"level":"info","message":"running speed tests on hashmap","timestamp":"2016-09-17T07:16:22.174Z"}
{"level":"info","message":"Hashmap.put() 1,000,000 (create) iterations took 2.29 seconds to execute.","timestamp":"2016-09-17T07:16:24.464Z"}
{"level":"info","message":"Hashmap.put() 1,000,000 (update) iterations took 1.616 seconds to execute.","timestamp":"2016-09-17T07:16:26.080Z"}
{"level":"info","message":"Hashmap.get() 1,000,000 iterations took 0.791 seconds to execute.","timestamp":"2016-09-17T07:16:26.871Z"}
{"level":"info","message":"Hashmap.next() 1,000,000 iterations took 0.014 seconds to execute.","timestamp":"2016-09-17T07:16:26.886Z"}
{"level":"info","message":"Hashmap.delete() 1,000,000 iterations took 1.922 seconds to execute.","timestamp":"2016-09-17T07:16:28.808Z"}
{"level":"info","message":"running speed tests on queue","timestamp":"2016-09-17T07:16:28.808Z"}
{"level":"info","message":"running speed tests on rolling hash","timestamp":"2016-09-17T07:16:28.823Z"}
{"level":"info","message":"Item was successfully found.","timestamp":"2016-09-17T07:16:29.206Z"}
{"level":"info","message":"RollingHash.slide() rolled over 2,114,349 characters in 0.383 seconds.","timestamp":"2016-09-17T07:16:29.206Z"}
{"level":"info","message":"Brute string matching searched through 2,114,349 characters in 0.05 seconds.","timestamp":"2016-09-17T07:16:29.257Z"}
{"level":"info","message":"Traditional substring locator searched through 2,114,349 characters in 56.317 seconds.","timestamp":"2016-09-17T07:17:25.574Z"}
{"level":"info","message":"running speed tests on singly linked list","timestamp":"2016-09-17T07:17:25.575Z"}
{"level":"info","message":"SinglyLinkedList.insertFront() 30,000 iterations took 0.005 seconds to execute.","timestamp":"2016-09-17T07:17:25.580Z"}
{"level":"info","message":"SinglyLinkedList.insertBack() 30,000 iterations took 2.3 seconds to execute.","timestamp":"2016-09-17T07:17:27.880Z"}
{"level":"info","message":"SinglyLinkedList.insertNth() 30,000 iterations took 2.09 seconds to execute.","timestamp":"2016-09-17T07:17:29.970Z"}
{"level":"info","message":"SinglyLinkedList.remove() 30,000 iterations took 2.537 seconds to execute.","timestamp":"2016-09-17T07:17:32.507Z"}
{"level":"info","message":"SinglyLinkedList.insertAfter() 30,000 iterations took 4.678 seconds to execute.","timestamp":"2016-09-17T07:17:37.186Z"}
{"level":"info","message":"SinglyLinkedList.find() 30,000 iterations took 0.008 seconds to execute.","timestamp":"2016-09-17T07:17:37.194Z"}
{"level":"info","message":"SinglyLinkedList.findNth() 30,000 iterations took 0.001 seconds to execute.","timestamp":"2016-09-17T07:17:37.195Z"}
{"level":"info","message":"SinglyLinkedList.removeNth() 30,000 iterations took 1.222 seconds to execute.","timestamp":"2016-09-17T07:17:38.417Z"}
{"level":"info","message":"running speed tests on sorted array","timestamp":"2016-09-17T07:17:38.418Z"}
{"level":"info","message":"SortedArray.insert() 500,000 (create) iterations took 61.511 seconds to execute.","timestamp":"2016-09-17T07:18:39.929Z"}
{"level":"info","message":"SortedArray.get() 500,000 iterations took 0.037 seconds to execute.","timestamp":"2016-09-17T07:18:39.966Z"}
{"level":"info","message":"SortedArray.delete() 500,000 (update) iterations took 0.129 seconds to execute.","timestamp":"2016-09-17T07:18:40.095Z"}
{"level":"info","message":"running speed tests on stack","timestamp":"2016-09-17T07:18:40.096Z"}
{"level":"info","message":"Stack.push() 1,000,000 iterations took 0.434 seconds to execute.","timestamp":"2016-09-17T07:18:40.530Z"}
{"level":"info","message":"Stack.peek() 1,000,000 iterations took 0.003 seconds to execute.","timestamp":"2016-09-17T07:18:40.533Z"}
{"level":"info","message":"Stack.pop() 1,000,000 iterations took 0.013 seconds to execute.","timestamp":"2016-09-17T07:18:40.546Z"}
2 changes: 1 addition & 1 deletion benchmarks/queue.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

'use strict';

var Needle = require('../src/needle.js');
var Needle = require('../src');
var winston = require('winston');
winston.log('info', 'running speed tests on queue');
var start, end, time, iterations, i;
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/rollingHash.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

'use strict';

var Needle = require('../src/needle.js');
var Needle = require('../src');
var LONG_TEXT = require('./long_text.js');
var winston = require('winston');
winston.log('info', 'running speed tests on rolling hash');
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/singlyLinkedList.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

'use strict';

var Needle = require('../src/needle.js');
var Needle = require('../src');
var winston = require('winston');
winston.log('info', 'running speed tests on singly linked list');
var start, end, time, iterations, i;
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/sortedArray.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

'use strict';

var Needle = require('../src/needle.js');
var Needle = require('../src');
var winston = require('winston');
winston.log('info', 'running speed tests on sorted array');
var start, end, time, iterations, i;
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/stack.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

'use strict';

var Needle = require('../src/needle.js');
var Needle = require('../src');
var winston = require('winston');
winston.log('info', 'running speed tests on stack');
var start, end, time, iterations, i;
Expand Down
2 changes: 1 addition & 1 deletion bin/needle.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion examples/scripts/needle.min.js

Large diffs are not rendered by default.

5 changes: 2 additions & 3 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,15 @@ gulp.task('dispatch', function(){
});

// Temporary patch to node-gyp searching wrong directory
// UPDATE: Don't think I need this anymore but keeping just
// in case.
// UPDATE: Don't think I need this anymore but keeping just in case.
gulp.task('patch', function(){
gulp.src(['scripts/build/**'])
.pipe(gulp.dest('build'));
});

// Watch files
gulp.task('watch', function(){
gulp.watch(['src/lib/*.js'], ['dispatch']);
gulp.watch(['src/**/*.js'], ['dispatch']);
});

// Set default to dispatch
Expand Down
File renamed without changes.
5 changes: 5 additions & 0 deletions src/BinaryHeap/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
'use strict';

const BinaryHeap = require('./binaryHeap');

module.exports = BinaryHeap;
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/**
/**
* Binary Search Tree
* {root} Node, the root of the tree
* {compare} function, compares two elements to each other to determine the ordering of the heap
* defaults to basic (a < b) => true
*
*
* Asymptotic time complexities
* +------------------------------+
* | hasRight | O(1) |
Expand All @@ -17,14 +17,14 @@
* | insert | O(n) |
* | search | O(n) |
* +------------------------------+
*
*
* TODO: let user set a custom `equal` function
*
*
*/

'use strict';

const Node = require('./nodes/bidirectional_tree_node.js');
const Node = require('../__Nodes__/bidirectional_tree_node.js');

/** @private @default
* Compares two elements and returns.
Expand Down Expand Up @@ -236,4 +236,4 @@ BinarySearchTree.prototype.search = function(data, node){
}
}

module.exports = BinarySearchTree;
module.exports = BinarySearchTree;
5 changes: 5 additions & 0 deletions src/BinarySearchTree/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
'use strict';

const BinarySearchTree = require('./binarySearchTree');

module.exports = BinarySearchTree;
File renamed without changes.
5 changes: 5 additions & 0 deletions src/BitArray/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
'use strict';

const BitArray = require('./bitArray');

module.exports = BitArray;
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

'use strict';

const Node = require('./nodes/bidirectional_node.js');
const Node = require('../__Nodes__/bidirectional_node.js');

/**
* Single argument constructor.
Expand Down
5 changes: 5 additions & 0 deletions src/DoublyLinkedList/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
'use strict';

const DoublyLinkedList = require('./doublyLinkedList');

module.exports = DoublyLinkedList;
10 changes: 5 additions & 5 deletions src/lib/hashmap.js → src/Hashmap/hashmap.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Hashmap
* {buckets} Array, the container of all the entries in the hashmap
* {current} Node, the node of the current entry in the hashmap
*
*
* Asymptotic time complexities
* +-------------------+
* | put | O(1) |
Expand All @@ -12,12 +12,12 @@
* | iterator | O(1) |
* | size | O(1) |
* +-------------------+
*
*
*/

'use strict';

const DoublyLinkedList = require('./doublyLinkedList.js');
const DoublyLinkedList = require('../DoublyLinkedList');

/** @private
* Takes in an argument and creates a unique hash derived from the given
Expand Down Expand Up @@ -68,7 +68,7 @@ function removeCustom(key, list){
const Hashmap = function(){
this.buckets = {};
this.current = undefined;

// This linked list will cache our entries locally so we can
// easily iterate through our entries.
this.list = new DoublyLinkedList();
Expand Down Expand Up @@ -176,4 +176,4 @@ Hashmap.prototype.size = function(){
return this.list.size;
}

module.exports = Hashmap;
module.exports = Hashmap;
5 changes: 5 additions & 0 deletions src/Hashmap/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
'use strict';

const Hashmap = require('./hashmap');

module.exports = Hashmap;
5 changes: 5 additions & 0 deletions src/KaryTree/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
'use strict';

const KaryTree = require('./KaryTree');

module.exports = KaryTree;
2 changes: 1 addition & 1 deletion src/lib/karyTree.js → src/KaryTree/karyTree.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

'use strict';

const Node = require('./nodes/multidirectional_tree_node.js');
const Node = require('../__Nodes__/multidirectional_tree_node.js');

/**
* Creates an empty k-ary tree.
Expand Down
5 changes: 5 additions & 0 deletions src/Queue/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
'use strict';

const Queue = require('./queue');

module.exports = Queue;
2 changes: 1 addition & 1 deletion src/lib/queue.js → src/Queue/queue.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*
*/

const Node = require('./nodes/unidirectional_node.js');
const Node = require('../__Nodes__/unidirectional_node.js');

/**
* Single argument constructor.
Expand Down
5 changes: 5 additions & 0 deletions src/RollingHash/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
'use strict';

const RollingHash = require('./rollingHash');

module.exports = RollingHash;
File renamed without changes.
5 changes: 5 additions & 0 deletions src/SinglyLinkedList/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
'use strict';

const SinglyLinkedList = require('./singlyLinkedList');

module.exports = SinglyLinkedList;
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

'use strict';

const Node = require('./nodes/unidirectional_node.js');
const Node = require('../__Nodes__/unidirectional_node.js');

/**
* Single argument constructor.
Expand Down
5 changes: 5 additions & 0 deletions src/SortedArray/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
'use strict';

const SortedArray = require('./sortedArray');

module.exports = SortedArray;
File renamed without changes.
5 changes: 5 additions & 0 deletions src/Stack/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
'use strict';

const Stack = require('./stack');

module.exports = Stack;
2 changes: 1 addition & 1 deletion src/lib/stack.js → src/Stack/stack.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

'use strict';

const Node = require('./nodes/unidirectional_node.js');
const Node = require('../__Nodes__/unidirectional_node.js');

/**
* Single argument constructor.
Expand Down
5 changes: 5 additions & 0 deletions src/Trie/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
'use strict';

const Trie = require('./trie');

module.exports = Trie;
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
38 changes: 38 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/**
* Needle definition file and export libs.
*/

'use strict';

const SinglyLinkedList = require('./SinglyLinkedList');
const Queue = require('./Queue');
const Stack = require('./Stack');
const DoublyLinkedList = require('./DoublyLinkedList');
const BinaryHeap = require('./BinaryHeap');
const BinarySearchTree = require('./BinarySearchTree');
const Hashmap = require('./Hashmap');
const SortedArray = require('./SortedArray');
const RollingHash = require('./RollingHash');
const BitArray = require('./BitArray');
const KaryTree = require('./KaryTree');

const Needle = {};

Needle.SinglyLinkedList = SinglyLinkedList;
Needle.Queue = Queue;
Needle.Stack = Stack;
Needle.DoublyLinkedList = DoublyLinkedList;
Needle.BinaryHeap = BinaryHeap;
Needle.BinarySearchTree = BinarySearchTree;
Needle.Hashmap = Hashmap;
Needle.SortedArray = SortedArray;
Needle.RollingHash = RollingHash;
Needle.BitArray = BitArray;
Needle.KaryTree = KaryTree;

exports = module.exports = Needle;

// If attempting to run in browser, add Needle to the global scope
if(typeof window !== 'undefined'){
window.Needle = Needle;
}
Loading

0 comments on commit 220c8ee

Please sign in to comment.