@jymfony/datastructure
Advanced tools
Comparing version 0.1.0-alpha.8 to 0.1.0-alpha.9
@@ -0,2 +1,3 @@ | ||
require('@jymfony/exceptions'); | ||
require('@jymfony/util'); | ||
require('./src/all'); |
{ | ||
"name": "@jymfony/datastructure", | ||
"version": "0.1.0-alpha.8", | ||
"version": "0.1.0-alpha.9", | ||
"description": "Jymfony Data Structures", | ||
@@ -21,6 +21,7 @@ "scripts": { | ||
"dependencies": { | ||
"@jymfony/exceptions": "0.1.0-alpha.8", | ||
"@jymfony/util": "0.1.0-alpha.8" | ||
"@jymfony/exceptions": "0.1.0-alpha.9", | ||
"@jymfony/util": "0.1.0-alpha.9" | ||
}, | ||
"devDependencies": { | ||
"@jymfony/autoloader": "https://github.com/jymfony/autoloader.git", | ||
"chai": "^3.5.0", | ||
@@ -27,0 +28,0 @@ "mocha": "^3.0" |
require('./PriorityQueue'); | ||
require('./BTree'); | ||
require('./HashTable'); |
@@ -1,27 +0,27 @@ | ||
require('../src/PriorityQueue'); | ||
require('../src/BTree'); | ||
const expect = require('chai').expect; | ||
let fillWithData = t => { | ||
t.push("www.example.org", "93.184.216.34"); | ||
t.push("www.twitter.com", "104.244.42.65"); | ||
t.push("www.facebook.com", "31.13.92.36"); | ||
t.push("www.simpsons.com", "209.052.165.60"); | ||
t.push("www.apple.com", "17.112.152.32"); | ||
t.push("www.amazon.com", "207.171.182.16"); | ||
t.push("www.ebay.com", "66.135.192.87"); | ||
t.push("www.cnn.com", "64.236.16.20"); | ||
t.push("www.google.com", "216.239.41.99"); | ||
t.push("www.nytimes.com", "199.239.136.200"); | ||
t.push("www.microsoft.com", "207.126.99.140"); | ||
t.push("www.ubuntu.org", "82.98.134.233"); | ||
t.push("www.sony.com", "23.33.68.135"); | ||
t.push("www.playstation.com", "23.32.11.42"); | ||
t.push("www.dell.com", "143.166.224.230"); | ||
t.push("www.slashdot.org", "66.35.250.151"); | ||
t.push("www.github.com", "192.30.253.112"); | ||
t.push("www.gitlab.com", "104.210.2.228"); | ||
t.push("www.bitbucket.com", "104.192.143.7"); | ||
t.push("www.espn.com", "199.181.135.201"); | ||
t.push("www.weather.com", "63.111.66.11"); | ||
t.push("www.yahoo.com", "216.109.118.65"); | ||
const fillWithData = t => { | ||
t.push('www.example.org', '93.184.216.34'); | ||
t.push('www.twitter.com', '104.244.42.65'); | ||
t.push('www.facebook.com', '31.13.92.36'); | ||
t.push('www.simpsons.com', '209.052.165.60'); | ||
t.push('www.apple.com', '17.112.152.32'); | ||
t.push('www.amazon.com', '207.171.182.16'); | ||
t.push('www.ebay.com', '66.135.192.87'); | ||
t.push('www.cnn.com', '64.236.16.20'); | ||
t.push('www.google.com', '216.239.41.99'); | ||
t.push('www.nytimes.com', '199.239.136.200'); | ||
t.push('www.microsoft.com', '207.126.99.140'); | ||
t.push('www.ubuntu.org', '82.98.134.233'); | ||
t.push('www.sony.com', '23.33.68.135'); | ||
t.push('www.playstation.com', '23.32.11.42'); | ||
t.push('www.dell.com', '143.166.224.230'); | ||
t.push('www.slashdot.org', '66.35.250.151'); | ||
t.push('www.github.com', '192.30.253.112'); | ||
t.push('www.gitlab.com', '104.210.2.228'); | ||
t.push('www.bitbucket.com', '104.192.143.7'); | ||
t.push('www.espn.com', '199.181.135.201'); | ||
t.push('www.weather.com', '63.111.66.11'); | ||
t.push('www.yahoo.com', '216.109.118.65'); | ||
}; | ||
@@ -31,3 +31,3 @@ | ||
it('toStringTag', () => { | ||
let t = new BTree(); | ||
const t = new BTree(); | ||
expect(t.toString()).to.be.equal('[object BTree]'); | ||
@@ -37,3 +37,3 @@ }); | ||
it('inspect', () => { | ||
let t = new BTree(); | ||
const t = new BTree(); | ||
expect(t.inspect()).to.be.instanceOf(Array); | ||
@@ -43,3 +43,3 @@ }); | ||
it('push throws if key is null', () => { | ||
let t = new BTree(); | ||
const t = new BTree(); | ||
expect(t.push.bind(t, null, 'foo')).to.throw(InvalidArgumentException); | ||
@@ -49,3 +49,3 @@ }); | ||
it('push throws if key is undefined', () => { | ||
let t = new BTree(); | ||
const t = new BTree(); | ||
expect(t.push.bind(t, undefined, 'foo')).to.throw(InvalidArgumentException); | ||
@@ -55,3 +55,3 @@ }); | ||
it('isEmpty', () => { | ||
let t = new BTree(); | ||
const t = new BTree(); | ||
expect(t.isEmpty()).to.be.true; | ||
@@ -64,3 +64,3 @@ | ||
it('clear', () => { | ||
let t = new BTree(); | ||
const t = new BTree(); | ||
expect(t.length).to.be.equal(0); | ||
@@ -77,6 +77,6 @@ | ||
it('copy', () => { | ||
let t = new BTree(); | ||
const t = new BTree(); | ||
fillWithData(t); | ||
let copy = t.copy(); | ||
const copy = t.copy(); | ||
expect(copy.length).to.be.equal(22); | ||
@@ -106,3 +106,3 @@ expect(copy.height).to.be.equal(3); | ||
[ 'www.weather.com', '63.111.66.11' ], | ||
[ 'www.yahoo.com', '216.109.118.65' ] | ||
[ 'www.yahoo.com', '216.109.118.65' ], | ||
]); | ||
@@ -122,24 +122,24 @@ | ||
it('search with equal key', () => { | ||
let t = new BTree(); | ||
const t = new BTree(); | ||
fillWithData(t); | ||
expect(t.search('www.github.com')).to.be.deep.equal(['www.github.com', '192.30.253.112']); | ||
expect(t.search('www.github.com')).to.be.deep.equal([ 'www.github.com', '192.30.253.112' ]); | ||
}); | ||
it('search with nearest lesser key', () => { | ||
let t = new BTree(); | ||
const t = new BTree(); | ||
fillWithData(t); | ||
expect(t.search('www.github', BTree.COMPARISON_LESSER)).to.be.deep.equal(['www.facebook.com', '31.13.92.36']); | ||
expect(t.search('www.github', BTree.COMPARISON_LESSER)).to.be.deep.equal([ 'www.facebook.com', '31.13.92.36' ]); | ||
}); | ||
it('search with nearest greater key', () => { | ||
let t = new BTree(); | ||
const t = new BTree(); | ||
fillWithData(t); | ||
expect(t.search('www.github', BTree.COMPARISON_GREATER)).to.be.deep.equal(['www.github.com', '192.30.253.112']); | ||
expect(t.search('www.github', BTree.COMPARISON_GREATER)).to.be.deep.equal([ 'www.github.com', '192.30.253.112' ]); | ||
}); | ||
it('length', () => { | ||
let t = new BTree(); | ||
const t = new BTree(); | ||
expect(t.length).to.be.equal(0); | ||
@@ -158,3 +158,3 @@ | ||
it('height', () => { | ||
let t = new BTree(); | ||
const t = new BTree(); | ||
fillWithData(t); | ||
@@ -166,3 +166,3 @@ | ||
it('toArray', () => { | ||
let t = new BTree(); | ||
const t = new BTree(); | ||
t.push('foo', 1); | ||
@@ -174,6 +174,6 @@ t.push('bar', 12); | ||
expect(t.toArray()).to.be.deep.equal([ | ||
['bar', 12], | ||
['baz', 1], | ||
['foo', 1], | ||
['foobar', 3] | ||
[ 'bar', 12 ], | ||
[ 'baz', 1 ], | ||
[ 'foo', 1 ], | ||
[ 'foobar', 3 ], | ||
]); | ||
@@ -180,0 +180,0 @@ expect(t.length).to.be.equal(4); |
@@ -6,3 +6,3 @@ require('../src/PriorityQueue'); | ||
it('toStringTag', () => { | ||
let q = new PriorityQueue(); | ||
const q = new PriorityQueue(); | ||
expect(q.toString()).to.be.equal('[object PriorityQueue]'); | ||
@@ -12,3 +12,3 @@ }); | ||
it('inspect', () => { | ||
let q = new PriorityQueue(); | ||
const q = new PriorityQueue(); | ||
expect(q.inspect()).to.be.instanceOf(Array); | ||
@@ -18,3 +18,3 @@ }); | ||
it('isEmpty', () => { | ||
let q = new PriorityQueue(); | ||
const q = new PriorityQueue(); | ||
expect(q.isEmpty()).to.be.true; | ||
@@ -27,3 +27,3 @@ | ||
it('clear', () => { | ||
let q = new PriorityQueue(); | ||
const q = new PriorityQueue(); | ||
expect(q.length).to.be.equal(0); | ||
@@ -40,12 +40,12 @@ | ||
it('copy', () => { | ||
let q = new PriorityQueue(); | ||
const q = new PriorityQueue(); | ||
q.push('foo', 1); | ||
q.push('bar', 0); | ||
let copy = q.copy(); | ||
expect(copy.toArray()).to.be.deep.equal(['foo', 'bar']); | ||
const copy = q.copy(); | ||
expect(copy.toArray()).to.be.deep.equal([ 'foo', 'bar' ]); | ||
}); | ||
it('length', () => { | ||
let q = new PriorityQueue(); | ||
const q = new PriorityQueue(); | ||
expect(q.length).to.be.equal(0); | ||
@@ -64,3 +64,3 @@ | ||
it('peek throws UnderflowException if queue is empty', () => { | ||
let q = new PriorityQueue(); | ||
const q = new PriorityQueue(); | ||
expect(q.peek.bind(q)).to.throw(UnderflowException); | ||
@@ -70,7 +70,7 @@ }); | ||
it('peek', () => { | ||
let q = new PriorityQueue(); | ||
const q = new PriorityQueue(); | ||
q.push('foo', 0); | ||
q.push('bar', 1); | ||
let first = q.peek(); | ||
const first = q.peek(); | ||
expect(first).to.be.equal('bar'); | ||
@@ -81,3 +81,3 @@ expect(q.length).to.be.equal(2); | ||
it('pop throws UnderflowException if queue is empty', () => { | ||
let q = new PriorityQueue(); | ||
const q = new PriorityQueue(); | ||
expect(q.pop.bind(q)).to.throw(UnderflowException); | ||
@@ -87,7 +87,7 @@ }); | ||
it('pop', () => { | ||
let q = new PriorityQueue(); | ||
const q = new PriorityQueue(); | ||
q.push('foo', 0); | ||
q.push('bar', 1); | ||
let first = q.pop(); | ||
const first = q.pop(); | ||
expect(first).to.be.equal('bar'); | ||
@@ -98,3 +98,3 @@ expect(q.length).to.be.equal(1); | ||
it('pops element in correct order', () => { | ||
let q = new PriorityQueue(); | ||
const q = new PriorityQueue(); | ||
q.push('foo', 1); | ||
@@ -113,3 +113,3 @@ q.push('bar', 12); | ||
it('push', () => { | ||
let q = new PriorityQueue(); | ||
const q = new PriorityQueue(); | ||
q.push('foo', 0); | ||
@@ -122,3 +122,3 @@ q.push('bar', 1); | ||
it('toArray', () => { | ||
let q = new PriorityQueue(); | ||
const q = new PriorityQueue(); | ||
q.push('foo', 1); | ||
@@ -129,3 +129,3 @@ q.push('bar', 12); | ||
expect(q.toArray()).to.be.deep.equal(['bar', 'foobar', 'foo', 'baz']); | ||
expect(q.toArray()).to.be.deep.equal([ 'bar', 'foobar', 'foo', 'baz' ]); | ||
expect(q.length).to.be.equal(4); | ||
@@ -135,3 +135,3 @@ }); | ||
it('iterator pops elements out', () => { | ||
let q = new PriorityQueue(); | ||
const q = new PriorityQueue(); | ||
q.push('foo', 1); | ||
@@ -143,3 +143,4 @@ q.push('bar', 12); | ||
let count = 4; | ||
for (let el of q) { | ||
for (const el of q) { | ||
expect(el).not.to.be.undefined; | ||
expect(q.length).to.be.equal(--count); | ||
@@ -146,0 +147,0 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
39540
15
1250
3
+ Added@jymfony/exceptions@0.1.0-alpha.9(transitive)
+ Added@jymfony/util@0.1.0-alpha.9(transitive)
- Removed@jymfony/exceptions@0.1.0-alpha.8(transitive)
- Removed@jymfony/util@0.1.0-alpha.8(transitive)
Updated@jymfony/util@0.1.0-alpha.9