Skip to content

Commit b1fd0b0

Browse files
committed
Navigable Map Testing
1 parent 7b8d95d commit b1fd0b0

37 files changed

+3562
-119
lines changed

definitions/index.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ export { List } from "./src/List";
2727
export { JMap } from "./src/JMap";
2828
export { JSet } from "./src/JSet";
2929
export { MapEntry } from "./src/MapEntry";
30+
export { NavigableHashMap } from "./src/NavigableHash";
31+
export { NavigableHashSet } from "./src/NavigableHash";
3032
export { NavigableMap } from "./src/NavigableMap";
3133
export { NavigableSet } from "./src/NavigableSet";
3234
export { PriorityQueue } from "./src/PriorityQueue";
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-
export {};
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-
export {};
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-
export {};
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-
export {};
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-
export {};
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-
export {};

definitions/spec/TestDeque.spec.d.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-
export {};
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-
export {};
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-
export {};
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-
export {};
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-
export {};
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-
export {};

definitions/spec/TestList.spec.d.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-
export {};

definitions/spec/TestMap.spec.d.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-
export {};
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-
export {};
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-
export {};
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-
export {};

definitions/spec/TestQueue.spec.d.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-
export {};

definitions/spec/TestSet.spec.d.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-
export {};
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-
export {};
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-
export {};

definitions/src/NavigableHash.d.ts

Lines changed: 435 additions & 0 deletions
Large diffs are not rendered by default.

dist/index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ var LinkedHashSet_1 = require("./src/LinkedHashSet");
2525
exports.LinkedHashSet = LinkedHashSet_1.LinkedHashSet;
2626
var LinkedList_1 = require("./src/LinkedList");
2727
exports.LinkedList = LinkedList_1.LinkedList;
28+
var NavigableHash_1 = require("./src/NavigableHash");
29+
exports.NavigableHashMap = NavigableHash_1.NavigableHashMap;
30+
var NavigableHash_2 = require("./src/NavigableHash");
31+
exports.NavigableHashSet = NavigableHash_2.NavigableHashSet;
2832
var PriorityQueue_1 = require("./src/PriorityQueue");
2933
exports.PriorityQueue = PriorityQueue_1.PriorityQueue;
3034
var SkipList_1 = require("./src/SkipList");

dist/spec/TestLinkedHashSet.spec.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ describe("Test LinkedHashSet functionality", function () {
140140
expect(values[2]).toEqual("1");
141141
});
142142
it("Test value jiterator three initial entries", function () {
143-
// makes new list unorder.. it uses set. see initializeElements()
143+
// makes new list unorder.. it uses set. see initializeElements()
144144
var sourceSet = new LinkedHashSet_1.LinkedHashSet(new AllFieldHashable_1.AllFieldHashable());
145145
expect(sourceSet.add("A")).toEqual(true);
146146
expect(sourceSet.add("C")).toEqual(true);
@@ -163,7 +163,7 @@ describe("Test LinkedHashSet functionality", function () {
163163
expect(values[2]).toEqual("A");
164164
});
165165
it("Test remove entry success", function () {
166-
// makes new list unorder.. it uses set. see initializeElements()
166+
// makes new list unorder.. it uses set. see initializeElements()
167167
var sourceSet = new LinkedHashSet_1.LinkedHashSet(new AllFieldHashable_1.AllFieldHashable());
168168
expect(sourceSet.add("A")).toEqual(true);
169169
expect(sourceSet.add("C")).toEqual(true);
@@ -184,7 +184,7 @@ describe("Test LinkedHashSet functionality", function () {
184184
expect(values[1]).toEqual("C");
185185
});
186186
it("Test remove entry failure", function () {
187-
// makes new list unorder.. it uses set. see initializeElements()
187+
// makes new list unorder.. it uses set. see initializeElements()
188188
var sourceSet = new LinkedHashSet_1.LinkedHashSet(new AllFieldHashable_1.AllFieldHashable());
189189
expect(sourceSet.add("A")).toEqual(true);
190190
expect(sourceSet.add("C")).toEqual(true);

dist/spec/TestMap.spec.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ var AllFieldHashable_1 = require("../src/AllFieldHashable");
1212
var Collections_1 = require("../src/Collections");
1313
var HashMap_1 = require("../src/HashMap");
1414
var LinkedHashMap_1 = require("../src/LinkedHashMap");
15+
var NavigableHash_1 = require("../src/NavigableHash");
1516
var SkipList_1 = require("../src/SkipList");
1617
var TreeMap_1 = require("../src/TreeMap");
1718
// PetStoreProduct will be used in testing
@@ -88,6 +89,9 @@ describe("Test Map functionality", function () {
8889
testEmptyStringStringMap(new SkipList_1.SkipListMap(Collections_1.Collections.getStringComparator()));
8990
testEmptyStringNumberMap(new SkipList_1.SkipListMap(Collections_1.Collections.getStringComparator()));
9091
testEmptyPetStoreProductAndValueClassMap(new SkipList_1.SkipListMap(alphabeticalSortPetStoreProduct));
92+
testEmptyStringStringMap(new NavigableHash_1.NavigableHashMap(Collections_1.Collections.getStringComparator()));
93+
testEmptyStringNumberMap(new NavigableHash_1.NavigableHashMap(Collections_1.Collections.getStringComparator()));
94+
testEmptyPetStoreProductAndValueClassMap(new NavigableHash_1.NavigableHashMap(alphabeticalSortPetStoreProduct));
9195
});
9296
it("Test adding to empty maps", function () {
9397
testAddingOneEntryStringStringMap(new HashMap_1.HashMap(), "HashMap default");
@@ -108,6 +112,9 @@ describe("Test Map functionality", function () {
108112
testAddingOneEntryStringStringMap(new SkipList_1.SkipListMap(Collections_1.Collections.getStringComparator()), "SkipListMap");
109113
testAddingOneEntryStringNumberMap(new SkipList_1.SkipListMap(Collections_1.Collections.getStringComparator()));
110114
testAddingOneEntryPetStoreProductAndValueClassMap(new SkipList_1.SkipListMap(alphabeticalSortPetStoreProduct));
115+
testAddingOneEntryStringStringMap(new NavigableHash_1.NavigableHashMap(Collections_1.Collections.getStringComparator()), "NavigableHashMap");
116+
testAddingOneEntryStringNumberMap(new NavigableHash_1.NavigableHashMap(Collections_1.Collections.getStringComparator()));
117+
testAddingOneEntryPetStoreProductAndValueClassMap(new NavigableHash_1.NavigableHashMap(alphabeticalSortPetStoreProduct));
111118
});
112119
it("Test adding two items to empty maps", function () {
113120
testAddingTwoEntriesStringStringMap(new HashMap_1.HashMap());
@@ -128,6 +135,9 @@ describe("Test Map functionality", function () {
128135
testAddingTwoEntriesStringStringMap(new SkipList_1.SkipListMap(Collections_1.Collections.getStringComparator()));
129136
testAddingTwoEntriesStringNumberMap(new SkipList_1.SkipListMap(Collections_1.Collections.getStringComparator()));
130137
testAddingTwoEntriesPetStoreProductAndValueClassMap(new SkipList_1.SkipListMap(alphabeticalSortPetStoreProduct));
138+
testAddingTwoEntriesStringStringMap(new NavigableHash_1.NavigableHashMap(Collections_1.Collections.getStringComparator()));
139+
testAddingTwoEntriesStringNumberMap(new NavigableHash_1.NavigableHashMap(Collections_1.Collections.getStringComparator()));
140+
testAddingTwoEntriesPetStoreProductAndValueClassMap(new NavigableHash_1.NavigableHashMap(alphabeticalSortPetStoreProduct));
131141
});
132142
it("Test clearing maps", function () {
133143
testClearingStringStringMap(new HashMap_1.HashMap());
@@ -148,6 +158,9 @@ describe("Test Map functionality", function () {
148158
testClearingStringStringMap(new SkipList_1.SkipListMap(Collections_1.Collections.getStringComparator()));
149159
testClearingStringNumberMap(new SkipList_1.SkipListMap(Collections_1.Collections.getStringComparator()));
150160
testClearingPetStoreProductAndValueClassMap(new SkipList_1.SkipListMap(alphabeticalSortPetStoreProduct));
161+
testClearingStringStringMap(new NavigableHash_1.NavigableHashMap(Collections_1.Collections.getStringComparator()));
162+
testClearingStringNumberMap(new NavigableHash_1.NavigableHashMap(Collections_1.Collections.getStringComparator()));
163+
testClearingPetStoreProductAndValueClassMap(new NavigableHash_1.NavigableHashMap(alphabeticalSortPetStoreProduct));
151164
});
152165
it("Test replacing entries", function () {
153166
testMapEntryReplacement(new HashMap_1.HashMap());
@@ -156,12 +169,14 @@ describe("Test Map functionality", function () {
156169
testMapEntryReplacement(new LinkedHashMap_1.LinkedHashMap(new AllFieldHashable_1.AllFieldHashable()));
157170
testMapEntryReplacement(new TreeMap_1.TreeMap(Collections_1.Collections.getStringComparator()));
158171
testMapEntryReplacement(new SkipList_1.SkipListMap(Collections_1.Collections.getStringComparator()));
172+
testMapEntryReplacement(new NavigableHash_1.NavigableHashMap(Collections_1.Collections.getStringComparator()));
159173
});
160174
it("Test copy constructor", function () {
161175
testCopyConstructor(new HashMap_1.HashMap(new AllFieldHashable_1.AllFieldHashable(), populateTestData(new HashMap_1.HashMap(new AllFieldHashable_1.AllFieldHashable()))));
162176
testCopyConstructor(new LinkedHashMap_1.LinkedHashMap(new AllFieldHashable_1.AllFieldHashable(), populateTestData(new LinkedHashMap_1.LinkedHashMap(new AllFieldHashable_1.AllFieldHashable()))));
163177
testCopyConstructor(new TreeMap_1.TreeMap(Collections_1.Collections.getStringComparator(), populateTestData(new TreeMap_1.TreeMap(Collections_1.Collections.getStringComparator()))));
164178
testCopyConstructor(new SkipList_1.SkipListMap(Collections_1.Collections.getStringComparator(), populateTestData(new SkipList_1.SkipListMap(Collections_1.Collections.getStringComparator()))));
179+
testCopyConstructor(new NavigableHash_1.NavigableHashMap(Collections_1.Collections.getStringComparator(), populateTestData(new NavigableHash_1.NavigableHashMap(Collections_1.Collections.getStringComparator()))));
165180
});
166181
});
167182
function testEmptyStringStringMap(map) {

dist/src/HashMap.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ var HashMap = /** @class */ (function () {
121121
* Rehashes the entire hashmap.... gonna be slow you've been warned
122122
*/
123123
HashMap.prototype.rehash = function () {
124-
if (this.elementCount > (this.data.size() * this.loadFactor)) { // Not enough buckets
124+
if (this.elementCount > (this.data.size() * this.loadFactor)) {
125125
// How many buckets should there be? Lets go with doubling the number of buckets
126126
var newBucketCount = (this.data.size() * 2) + 1;
127127
var newdata = new ArrayList_1.ArrayList(this.ListMapEntryMethods);
@@ -435,7 +435,7 @@ var HashMapKeySetJIterator = /** @class */ (function () {
435435
this.map = iHashMap;
436436
}
437437
HashMapKeySetJIterator.prototype.hasNext = function () {
438-
if (this.location === undefined) { // first time caller
438+
if (this.location === undefined) {
439439
var firstEntry = this.map.deprecatedGetFirstEntryForIterator();
440440
if ((firstEntry === null) || (firstEntry === undefined))
441441
return false;
@@ -444,7 +444,7 @@ var HashMapKeySetJIterator = /** @class */ (function () {
444444
var first = firstEntry.entry.getKey();
445445
return true;
446446
}
447-
else { // we've already called this iterator before
447+
else {
448448
var tmpEntry = this.map.deprecatedGetNextEntryForIterator(this.location);
449449
if ((tmpEntry === null) || (tmpEntry === undefined))
450450
return false;
@@ -455,7 +455,7 @@ var HashMapKeySetJIterator = /** @class */ (function () {
455455
}
456456
};
457457
HashMapKeySetJIterator.prototype.next = function () {
458-
if (this.location === undefined) { // first time caller
458+
if (this.location === undefined) {
459459
var firstEntry = this.map.deprecatedGetFirstEntryForIterator();
460460
if ((firstEntry === null) || (firstEntry === undefined))
461461
return null;
@@ -465,7 +465,7 @@ var HashMapKeySetJIterator = /** @class */ (function () {
465465
this.location = firstEntry;
466466
return first;
467467
}
468-
else { // we've already called this iterator before
468+
else {
469469
var tmpEntry = this.map.deprecatedGetNextEntryForIterator(this.location);
470470
if ((tmpEntry === null) || (tmpEntry === undefined))
471471
return null;
@@ -524,7 +524,7 @@ var HashMapEntrySetJIterator = /** @class */ (function () {
524524
this.map = iHashMap;
525525
}
526526
HashMapEntrySetJIterator.prototype.hasNext = function () {
527-
if (this.location === undefined) { // first time caller
527+
if (this.location === undefined) {
528528
var firstEntry = this.map.deprecatedGetFirstEntryForIterator();
529529
if ((firstEntry === null) || (firstEntry === undefined))
530530
return null;
@@ -533,7 +533,7 @@ var HashMapEntrySetJIterator = /** @class */ (function () {
533533
var first = firstEntry.entry.getKey();
534534
return true;
535535
}
536-
else { // we've already called this iterator before
536+
else {
537537
var tmpEntry = this.map.deprecatedGetNextEntryForIterator(this.location);
538538
if ((tmpEntry === null) || (tmpEntry === undefined))
539539
return null;
@@ -544,7 +544,7 @@ var HashMapEntrySetJIterator = /** @class */ (function () {
544544
}
545545
};
546546
HashMapEntrySetJIterator.prototype.next = function () {
547-
if (this.location === undefined) { // first time caller
547+
if (this.location === undefined) {
548548
var firstEntry = this.map.deprecatedGetFirstEntryForIterator();
549549
if ((firstEntry === null) || (firstEntry === undefined))
550550
return null;
@@ -554,7 +554,7 @@ var HashMapEntrySetJIterator = /** @class */ (function () {
554554
this.location = firstEntry;
555555
return first;
556556
}
557-
else { // we've already called this iterator before
557+
else {
558558
var tmpEntry = this.map.deprecatedGetNextEntryForIterator(this.location);
559559
if ((tmpEntry === null) || (tmpEntry === undefined))
560560
return null;

dist/src/HashSet.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ var HashSetJIterator = /** @class */ (function () {
179179
this.set = iSet;
180180
}
181181
HashSetJIterator.prototype.hasNext = function () {
182-
if (this.location === undefined) { // first time caller
182+
if (this.location === undefined) {
183183
var first = this.set.deprecatedGetFirstEntryForIterator();
184184
if (first === undefined) {
185185
return false;
@@ -189,7 +189,7 @@ var HashSetJIterator = /** @class */ (function () {
189189
}
190190
return true;
191191
}
192-
else { // we've already called this iterator before
192+
else {
193193
var tmp = this.set.deprecatedGetNextEntryForIterator(this.location);
194194
if (tmp === null) {
195195
return false;
@@ -200,7 +200,7 @@ var HashSetJIterator = /** @class */ (function () {
200200
}
201201
};
202202
HashSetJIterator.prototype.next = function () {
203-
if (this.location === undefined) { // first time caller
203+
if (this.location === undefined) {
204204
var first = this.set.deprecatedGetFirstEntryForIterator();
205205
if (first === undefined) {
206206
return null;
@@ -211,7 +211,7 @@ var HashSetJIterator = /** @class */ (function () {
211211
this.location = first;
212212
return first.entry.getKey();
213213
}
214-
else { // we've already called this iterator before
214+
else {
215215
var tmp = this.set.deprecatedGetNextEntryForIterator(this.location);
216216
if (tmp === null) {
217217
return null;

0 commit comments

Comments
 (0)