Replace LLMap with Map

This commit is contained in:
Leilei332
2025-09-13 21:22:01 +08:00
parent 894cb479ea
commit 4410ac194a

View File

@@ -16,8 +16,8 @@ function LinkedList() {
LinkedList.prototype.clear = function() {
// LinkedList performs the duty of both the head and tail node
this.next = new LLMap();
this.prev = new LLMap();
this.next = new Map();
this.prev = new Map();
// Linked list head initially points to itself
this.next.set(null, null);
this.prev.set(null, null);
@@ -190,18 +190,4 @@ function _assertString(value) {
}
};
var LLMap = function() {
this.map = Object.create(null);
};
// Just a wrapper so our object map can also accept null.
LLMap.prototype = {
set: function(key,val) {
(key === null) ? (this.null = val) : (this.map[key] = val);
},
get: function(key) {
return (key === null) ? this.null : this.map[key];
}
};
exports.LinkedList = LinkedList;