@js-sdsl/stack
Advanced tools
Comparing version 4.2.0-beta.1 to 4.2.0
@@ -7,2 +7,24 @@ # Change Log | ||
## [4.2.0] - 2022.11.20 | ||
### Changed | ||
- Optimized the structure of class `TreeNodeEnableIndex`. | ||
- Change the `iterator access denied` error message to reduce the packing size. | ||
- Change the internal storage of the hash container to the form of a linked list, traversing in insertion order. | ||
- Standardize hash container. Make it extends from `Container` and add general functions. | ||
- Refactor `LinkList` to do optimization. | ||
### Added | ||
- Add public `length` property to all the container. | ||
- Add returned value to `pop` function including `popBack` and `popFront` to all the container which has such function. | ||
- Add returned value to `eraseElementByKey` which means whether erase successfully. | ||
- Add returned value to `push` or `insert` function which means the size of the container. | ||
### Fixed | ||
- Fixed wrong error type when `updateKeyByIterator`. | ||
- Fixed wrong iterator was returned when erase tree reverse iterator. | ||
## [4.2.0-beta.1] - 2022.11.06 | ||
@@ -9,0 +31,0 @@ |
declare abstract class Base { | ||
/** | ||
* @return The size of the container. | ||
* @returns The size of the container. | ||
* @example | ||
* const container = new Vector([1, 2]); | ||
* console.log(container.length); // 2 | ||
*/ | ||
get length(): number; | ||
/** | ||
* @returns The size of the container. | ||
* @example | ||
* const container = new Vector([1, 2]); | ||
* console.log(container.size()); // 2 | ||
@@ -10,3 +17,3 @@ */ | ||
/** | ||
* @return Boolean about if the container is empty. | ||
* @returns Whether the container is empty. | ||
* @example | ||
@@ -25,2 +32,5 @@ * container.clear(); | ||
} | ||
/** | ||
* @description The initial data type passed in when initializing the container. | ||
*/ | ||
type initContainer<T> = ({ | ||
@@ -40,10 +50,14 @@ size: number; | ||
* @description Insert element to stack's end. | ||
* @description The element you want to push to the back. | ||
* @returns The container length after erasing. | ||
*/ | ||
push(element: T): void; | ||
push(element: T): number; | ||
/** | ||
* @description Removes the end element. | ||
* @returns The element you popped. | ||
*/ | ||
pop(): void; | ||
pop(): T | undefined; | ||
/** | ||
* @description Accesses the end element. | ||
* @returns The last element. | ||
*/ | ||
@@ -50,0 +64,0 @@ top(): T | undefined; |
@@ -11,2 +11,5 @@ "use strict"; | ||
} | ||
get length() { | ||
return this.i; | ||
} | ||
size() { | ||
@@ -31,3 +34,3 @@ return this.i; | ||
this.i = 0; | ||
this.h.length = 0; | ||
this.h = []; | ||
} | ||
@@ -37,6 +40,8 @@ push(t) { | ||
this.i += 1; | ||
return this.i; | ||
} | ||
pop() { | ||
this.h.pop(); | ||
if (this.i > 0) this.i -= 1; | ||
if (this.i === 0) return; | ||
this.i -= 1; | ||
return this.h.pop(); | ||
} | ||
@@ -43,0 +48,0 @@ top() { |
declare abstract class Base { | ||
/** | ||
* @return The size of the container. | ||
* @returns The size of the container. | ||
* @example | ||
* const container = new Vector([1, 2]); | ||
* console.log(container.length); // 2 | ||
*/ | ||
get length(): number; | ||
/** | ||
* @returns The size of the container. | ||
* @example | ||
* const container = new Vector([1, 2]); | ||
* console.log(container.size()); // 2 | ||
@@ -10,3 +17,3 @@ */ | ||
/** | ||
* @return Boolean about if the container is empty. | ||
* @returns Whether the container is empty. | ||
* @example | ||
@@ -25,2 +32,5 @@ * container.clear(); | ||
} | ||
/** | ||
* @description The initial data type passed in when initializing the container. | ||
*/ | ||
type initContainer<T> = ({ | ||
@@ -40,10 +50,14 @@ size: number; | ||
* @description Insert element to stack's end. | ||
* @description The element you want to push to the back. | ||
* @returns The container length after erasing. | ||
*/ | ||
push(element: T): void; | ||
push(element: T): number; | ||
/** | ||
* @description Removes the end element. | ||
* @returns The element you popped. | ||
*/ | ||
pop(): void; | ||
pop(): T | undefined; | ||
/** | ||
* @description Accesses the end element. | ||
* @returns The last element. | ||
*/ | ||
@@ -50,0 +64,0 @@ top(): T | undefined; |
@@ -7,3 +7,3 @@ var extendStatics = function(t, n) { | ||
} || function(t, n) { | ||
for (var i in n) if (Object.prototype.hasOwnProperty.call(n, i)) t[i] = n[i]; | ||
for (var e in n) if (Object.prototype.hasOwnProperty.call(n, e)) t[e] = n[e]; | ||
}; | ||
@@ -26,2 +26,9 @@ return extendStatics(t, n); | ||
} | ||
Object.defineProperty(Base.prototype, "length", { | ||
get: function() { | ||
return this.t; | ||
}, | ||
enumerable: false, | ||
configurable: true | ||
}); | ||
Base.prototype.size = function() { | ||
@@ -50,13 +57,13 @@ return this.t; | ||
} | ||
var i = t.call(this) || this; | ||
i.i = []; | ||
var e = i; | ||
var e = t.call(this) || this; | ||
e.i = []; | ||
var i = e; | ||
n.forEach((function(t) { | ||
e.push(t); | ||
i.push(t); | ||
})); | ||
return i; | ||
return e; | ||
} | ||
Stack.prototype.clear = function() { | ||
this.t = 0; | ||
this.i.length = 0; | ||
this.i = []; | ||
}; | ||
@@ -66,6 +73,8 @@ Stack.prototype.push = function(t) { | ||
this.t += 1; | ||
return this.t; | ||
}; | ||
Stack.prototype.pop = function() { | ||
this.i.pop(); | ||
if (this.t > 0) this.t -= 1; | ||
if (this.t === 0) return; | ||
this.t -= 1; | ||
return this.i.pop(); | ||
}; | ||
@@ -72,0 +81,0 @@ Stack.prototype.top = function() { |
/*! | ||
* @js-sdsl/stack v4.2.0-beta.1 | ||
* @js-sdsl/stack v4.2.0 | ||
* https://github.com/js-sdsl/js-sdsl | ||
@@ -57,4 +57,17 @@ * (c) 2021-present ZLY201 <zilongyao1366@gmail.com> | ||
} | ||
Object.defineProperty(Base.prototype, "length", { | ||
/** | ||
* @returns The size of the container. | ||
* @example | ||
* const container = new Vector([1, 2]); | ||
* console.log(container.length); // 2 | ||
*/ | ||
get: function () { | ||
return this._length; | ||
}, | ||
enumerable: false, | ||
configurable: true | ||
}); | ||
/** | ||
* @return The size of the container. | ||
* @returns The size of the container. | ||
* @example | ||
@@ -68,3 +81,3 @@ * const container = new Vector([1, 2]); | ||
/** | ||
* @return Boolean about if the container is empty. | ||
* @returns Whether the container is empty. | ||
* @example | ||
@@ -106,6 +119,8 @@ * container.clear(); | ||
this._length = 0; | ||
this._stack.length = 0; | ||
this._stack = []; | ||
}; | ||
/** | ||
* @description Insert element to stack's end. | ||
* @description The element you want to push to the back. | ||
* @returns The container length after erasing. | ||
*/ | ||
@@ -115,12 +130,16 @@ Stack.prototype.push = function (element) { | ||
this._length += 1; | ||
return this._length; | ||
}; | ||
/** | ||
* @description Removes the end element. | ||
* @returns The element you popped. | ||
*/ | ||
Stack.prototype.pop = function () { | ||
this._stack.pop(); | ||
if (this._length > 0) this._length -= 1; | ||
if (this._length === 0) return; | ||
this._length -= 1; | ||
return this._stack.pop(); | ||
}; | ||
/** | ||
* @description Accesses the end element. | ||
* @returns The last element. | ||
*/ | ||
@@ -127,0 +146,0 @@ Stack.prototype.top = function () { |
/*! | ||
* @js-sdsl/stack v4.2.0-beta.1 | ||
* @js-sdsl/stack v4.2.0 | ||
* https://github.com/js-sdsl/js-sdsl | ||
@@ -7,3 +7,3 @@ * (c) 2021-present ZLY201 <zilongyao1366@gmail.com> | ||
*/ | ||
!function(t,o){"object"==typeof exports&&"undefined"!=typeof module?o(exports):"function"==typeof define&&define.amd?define(["exports"],o):o((t="undefined"!=typeof globalThis?globalThis:t||self).sdsl={})}(this,function(t){"use strict";var e=function(t,o){return(e=Object.setPrototypeOf||({__proto__:[]}instanceof Array?function(t,o){t.__proto__=o}:function(t,o){for(var n in o)Object.prototype.hasOwnProperty.call(o,n)&&(t[n]=o[n])}))(t,o)};function o(t,o){if("function"!=typeof o&&null!==o)throw new TypeError("Class extends value "+String(o)+" is not a constructor or null");function n(){this.constructor=t}e(t,o),t.prototype=null===o?Object.create(o):(n.prototype=o.prototype,new n)}r.prototype.size=function(){return this.t},r.prototype.empty=function(){return 0===this.t};var n,i=r;function r(){this.t=0}function p(){return null!==n&&n.apply(this,arguments)||this}o(p,n=i);o(u,s=i),u.prototype.clear=function(){this.t=0,this.i.length=0},u.prototype.push=function(t){this.i.push(t),this.t+=1},u.prototype.pop=function(){this.i.pop(),0<this.t&&--this.t},u.prototype.top=function(){return this.i[this.t-1]};var s,i=u;function u(t){void 0===t&&(t=[]);var o=s.call(this)||this,n=(o.i=[],o);return t.forEach(function(t){n.push(t)}),o}t.Stack=i,Object.defineProperty(t,"o",{value:!0})}); | ||
!function(t,o){"object"==typeof exports&&"undefined"!=typeof module?o(exports):"function"==typeof define&&define.amd?define(["exports"],o):o((t="undefined"!=typeof globalThis?globalThis:t||self).sdsl={})}(this,function(t){"use strict";var e=function(t,o){return(e=Object.setPrototypeOf||({__proto__:[]}instanceof Array?function(t,o){t.__proto__=o}:function(t,o){for(var n in o)Object.prototype.hasOwnProperty.call(o,n)&&(t[n]=o[n])}))(t,o)};function o(t,o){if("function"!=typeof o&&null!==o)throw new TypeError("Class extends value "+String(o)+" is not a constructor or null");function n(){this.constructor=t}e(t,o),t.prototype=null===o?Object.create(o):(n.prototype=o.prototype,new n)}Object.defineProperty(i.prototype,"length",{get:function(){return this.t},enumerable:!1,configurable:!0}),i.prototype.size=function(){return this.t},i.prototype.empty=function(){return 0===this.t};var n,r=i;function i(){this.t=0}function p(){return null!==n&&n.apply(this,arguments)||this}o(p,n=r);o(s,u=r),s.prototype.clear=function(){this.t=0,this.i=[]},s.prototype.push=function(t){return this.i.push(t),this.t+=1,this.t},s.prototype.pop=function(){if(0!==this.t)return--this.t,this.i.pop()},s.prototype.top=function(){return this.i[this.t-1]};var u,r=s;function s(t){void 0===t&&(t=[]);var o=u.call(this)||this,n=(o.i=[],o);return t.forEach(function(t){n.push(t)}),o}t.Stack=r,Object.defineProperty(t,"u",{value:!0})}); | ||
//# sourceMappingURL=stack.min.js.map |
{ | ||
"name": "@js-sdsl/stack", | ||
"version": "4.2.0-beta.1", | ||
"version": "4.2.0", | ||
"description": "javascript standard data structure library which benchmark against C++ STL", | ||
@@ -5,0 +5,0 @@ "main": "./dist/cjs/index.js", |
<p align="center"> | ||
<a href="https://js-sdsl.org/" target="_blank" rel="noopener noreferrer"> | ||
<img src="https://js-sdsl.org/assets/logo-removebg.png" alt="js-sdsl logo" width="120" /> | ||
<img src="https://js-sdsl.org/assets/image/logo/logo-removebg.png" alt="js-sdsl logo" width="120" /> | ||
</a> | ||
@@ -45,23 +45,23 @@ </p> | ||
<td> | ||
<img alt="IE / Edge" src="https://www.w3schools.com/images/compatible_edge2020.png" /> | ||
<img alt="IE / Edge" src="https://js-sdsl.org/assets/image/platform/edge.png" /> | ||
<div>IE / Edge</div> | ||
</td> | ||
<td> | ||
<img alt="Firefox" src="https://www.w3schools.com/images/compatible_firefox2020.png" /> | ||
<img alt="Firefox" src="https://js-sdsl.org/assets/image/platform/firefox.png" /> | ||
<div>Firefox</div> | ||
</td> | ||
<td> | ||
<img alt="Chrome" src="https://www.w3schools.com/images/compatible_chrome2020.png" /> | ||
<img alt="Chrome" src="https://js-sdsl.org/assets/image/platform/chrome.png" /> | ||
<div>Chrome</div> | ||
</td> | ||
<td> | ||
<img alt="Safari" src="https://www.w3schools.com/images/compatible_safari2020.png" /> | ||
<img alt="Safari" src="https://js-sdsl.org/assets/image/platform/safari.png" /> | ||
<div>Safari</div> | ||
</td> | ||
<td> | ||
<img alt="Opera" src="https://www.w3schools.com/images/compatible_opera2020.png" /> | ||
<img alt="Opera" src="https://js-sdsl.org/assets/image/platform/opera.png" /> | ||
<div>Opera</div> | ||
</td> | ||
<td> | ||
<img alt="NodeJs" src="https://cdn-icons-png.flaticon.com/512/5968/5968322.png" width="20" /> | ||
<img alt="NodeJs" src="https://js-sdsl.org/assets/image/platform/nodejs.png" /> | ||
<div>NodeJs</div> | ||
@@ -217,3 +217,3 @@ </td> | ||
<a href="https://eslint.org/"><img src="https://js-sdsl.org/assets/sponsors/eslint-logo-color.png" alt="eslint logo" width="150"></a> | ||
<a href="https://eslint.org/"><img src="https://js-sdsl.org/assets/image/sponsors/eslint-logo-color.png" alt="eslint logo" width="150"></a> | ||
@@ -220,0 +220,0 @@ Thanks also give to these sponsors or backers: |
<p align="center"> | ||
<a href="https://js-sdsl.org/" target="_blank" rel="noopener noreferrer"> | ||
<img src="https://js-sdsl.org/assets/logo-removebg.png" alt="js-sdsl logo" width="120" /> | ||
<img src="https://js-sdsl.org/assets/image/logo/logo-removebg.png" alt="js-sdsl logo" width="120" /> | ||
</a> | ||
@@ -47,23 +47,23 @@ </p> | ||
<td> | ||
<img alt="IE / Edge" src="https://www.w3schools.com/images/compatible_edge2020.png" /> | ||
<img alt="IE / Edge" src="https://js-sdsl.org/assets/image/platform/edge.png" /> | ||
<div>IE / Edge</div> | ||
</td> | ||
<td> | ||
<img alt="Firefox" src="https://www.w3schools.com/images/compatible_firefox2020.png" /> | ||
<img alt="Firefox" src="https://js-sdsl.org/assets/image/platform/firefox.png" /> | ||
<div>Firefox</div> | ||
</td> | ||
<td> | ||
<img alt="Chrome" src="https://www.w3schools.com/images/compatible_chrome2020.png" /> | ||
<img alt="Chrome" src="https://js-sdsl.org/assets/image/platform/chrome.png" /> | ||
<div>Chrome</div> | ||
</td> | ||
<td> | ||
<img alt="Safari" src="https://www.w3schools.com/images/compatible_safari2020.png" /> | ||
<img alt="Safari" src="https://js-sdsl.org/assets/image/platform/safari.png" /> | ||
<div>Safari</div> | ||
</td> | ||
<td> | ||
<img alt="Opera" src="https://www.w3schools.com/images/compatible_opera2020.png" /> | ||
<img alt="Opera" src="https://js-sdsl.org/assets/image/platform/opera.png" /> | ||
<div>Opera</div> | ||
</td> | ||
<td> | ||
<img alt="NodeJs" src="https://cdn-icons-png.flaticon.com/512/5968/5968322.png" width="20" /> | ||
<img alt="NodeJs" src="https://js-sdsl.org/assets/image/platform/nodejs.png" /> | ||
<div>NodeJs</div> | ||
@@ -219,3 +219,3 @@ </td> | ||
<a href="https://eslint.org/"><img src="https://js-sdsl.org/assets/sponsors/eslint-logo-color.png" alt="eslint logo" width="150"></a> | ||
<a href="https://eslint.org/"><img src="https://js-sdsl.org/assets/image/sponsors/eslint-logo-color.png" alt="eslint logo" width="150"></a> | ||
@@ -222,0 +222,0 @@ 同样感谢这些赞助商和支持者们: |
Sorry, the diff of this file is not supported yet
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
96488
407
0