data-footstone
Advanced tools
Comparing version 0.1.6 to 0.1.7
@@ -151,13 +151,6 @@ 'use strict'; | ||
if (this.chain.tail.value.count > newCount) { | ||
this.chain.append(newCount); | ||
this.chain.append(newNode); | ||
} | ||
else { | ||
let cur = this.chain.head; | ||
while (cur) { | ||
if (cur.value.count <= newCount) { | ||
break; | ||
} | ||
cur = cur.next; | ||
} | ||
this.chain.insert(newNode, cur.position); | ||
this._insert(newNode); | ||
} | ||
@@ -171,2 +164,12 @@ } | ||
} | ||
_insert(node) { | ||
let cur = this.chain.head; | ||
while (cur) { | ||
if (cur.value.count <= node.count) { | ||
break; | ||
} | ||
cur = cur.next; | ||
} | ||
this.chain.insert(node, cur.position); | ||
} | ||
put(k, v) { | ||
@@ -179,10 +182,3 @@ let node = this._get(k); | ||
node.value.value = v; | ||
let cur = this.chain.head; | ||
while (cur) { | ||
if (cur.value.count <= node.value.count) { | ||
break; | ||
} | ||
cur = cur.next; | ||
} | ||
this.chain.insert(node, cur.position); | ||
this._insert(node.value); | ||
} | ||
@@ -195,3 +191,8 @@ else { | ||
let newNode = this._createNode(k, v, 1); | ||
this.chain.append(newNode); | ||
if (this.chain.head) { | ||
this._insert(newNode); | ||
} | ||
else { | ||
this.chain.append(newNode); | ||
} | ||
} | ||
@@ -198,0 +199,0 @@ return this.size(); |
@@ -149,13 +149,6 @@ import { SingleChain, DoublyChain } from './chain.js'; | ||
if (this.chain.tail.value.count > newCount) { | ||
this.chain.append(newCount); | ||
this.chain.append(newNode); | ||
} | ||
else { | ||
let cur = this.chain.head; | ||
while (cur) { | ||
if (cur.value.count <= newCount) { | ||
break; | ||
} | ||
cur = cur.next; | ||
} | ||
this.chain.insert(newNode, cur.position); | ||
this._insert(newNode); | ||
} | ||
@@ -169,2 +162,12 @@ } | ||
} | ||
_insert(node) { | ||
let cur = this.chain.head; | ||
while (cur) { | ||
if (cur.value.count <= node.count) { | ||
break; | ||
} | ||
cur = cur.next; | ||
} | ||
this.chain.insert(node, cur.position); | ||
} | ||
put(k, v) { | ||
@@ -177,10 +180,3 @@ let node = this._get(k); | ||
node.value.value = v; | ||
let cur = this.chain.head; | ||
while (cur) { | ||
if (cur.value.count <= node.value.count) { | ||
break; | ||
} | ||
cur = cur.next; | ||
} | ||
this.chain.insert(node, cur.position); | ||
this._insert(node.value); | ||
} | ||
@@ -193,3 +189,8 @@ else { | ||
let newNode = this._createNode(k, v, 1); | ||
this.chain.append(newNode); | ||
if (this.chain.head) { | ||
this._insert(newNode); | ||
} | ||
else { | ||
this.chain.append(newNode); | ||
} | ||
} | ||
@@ -196,0 +197,0 @@ return this.size(); |
{ | ||
"name": "data-footstone", | ||
"version": "0.1.6", | ||
"version": "0.1.7", | ||
"description": "data structure", | ||
@@ -75,3 +75,3 @@ "author": "feigebaobei <18515195415@163.com>", | ||
}, | ||
"gitHead": "47e74dbdff2145571f6e3938d9515d800cf07a3d" | ||
"gitHead": "860a90cbc6878943c09e2d31e4d12fa4d0dce078" | ||
} |
@@ -189,13 +189,6 @@ // 存储 | ||
if (this.chain.tail.value.count > newCount) { | ||
this.chain.append(newCount); | ||
this.chain.append(newNode); | ||
} | ||
else { | ||
let cur = this.chain.head; | ||
while (cur) { | ||
if (cur.value.count <= newCount) { | ||
break; | ||
} | ||
cur = cur.next; | ||
} | ||
this.chain.insert(newNode, cur.position); | ||
this._insert(newNode); | ||
} | ||
@@ -209,2 +202,12 @@ } | ||
} | ||
_insert(node) { | ||
let cur = this.chain.head; | ||
while (cur) { | ||
if (cur.value.count <= node.count) { | ||
break; | ||
} | ||
cur = cur.next; | ||
} | ||
this.chain.insert(node, cur.position); | ||
} | ||
put(k, v) { | ||
@@ -217,10 +220,3 @@ let node = this._get(k); | ||
node.value.value = v; | ||
let cur = this.chain.head; | ||
while (cur) { | ||
if (cur.value.count <= node.value.count) { | ||
break; | ||
} | ||
cur = cur.next; | ||
} | ||
this.chain.insert(node, cur.position); | ||
this._insert(node.value); | ||
} | ||
@@ -233,3 +229,8 @@ else { | ||
let newNode = this._createNode(k, v, 1); | ||
this.chain.append(newNode); | ||
if (this.chain.head) { | ||
this._insert(newNode); | ||
} | ||
else { | ||
this.chain.append(newNode); | ||
} | ||
} | ||
@@ -236,0 +237,0 @@ return this.size(); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
5399
339530