New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@js-sdsl/vector

Package Overview
Dependencies
Maintainers
2
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@js-sdsl/vector - npm Package Compare versions

Comparing version 4.2.0 to 4.3.0

10

CHANGELOG.md

@@ -7,2 +7,12 @@ # Change Log

## [4.3.0] - 2023.01.20
### Added
- Add public member `container` to `Iterator` which means the container that the iterator pointed to.
### Changed
- Reimplement `Queue`, separate `Queue` from `Deque`.
## [4.2.0] - 2022.11.20

@@ -9,0 +19,0 @@

19

dist/cjs/index.d.ts

@@ -10,2 +10,6 @@ /**

/**
* @description The container pointed to by the iterator.
*/
abstract readonly container: Container<T>;
/**
* @description Iterator's type.

@@ -199,10 +203,6 @@ * @example

*/
type initContainer<T> = ({
size: number;
} | {
length: number;
} | {
size(): number;
}) & {
forEach(callback: (element: T) => void): void;
type initContainer<T> = {
size?: number | (() => number);
length?: number;
forEach: (callback: (el: T) => void) => void;
};

@@ -275,2 +275,3 @@ declare abstract class SequentialContainer<T> extends Container<T> {

declare abstract class RandomIterator<T> extends ContainerIterator<T> {
abstract readonly container: SequentialContainer<T>;
get pointer(): T;

@@ -284,2 +285,4 @@ set pointer(newValue: T);

declare class VectorIterator<T> extends RandomIterator<T> {
container: Vector<T>;
constructor(node: number, container: Vector<T>, iteratorType?: IteratorType);
copy(): VectorIterator<T>;

@@ -286,0 +289,0 @@ // @ts-ignore

@@ -40,8 +40,5 @@ "use strict";

class RandomIterator extends ContainerIterator {
constructor(t, r, s, e, i) {
super(i);
constructor(t, r) {
super(r);
this.i = t;
this.o = r;
this.u = s;
this.l = e;
if (this.iteratorType === 0) {

@@ -56,3 +53,3 @@ this.pre = function() {

this.next = function() {
if (this.i === this.o()) {
if (this.i === this.container.size()) {
throwIteratorAccessError();

@@ -65,3 +62,3 @@ }

this.pre = function() {
if (this.i === this.o() - 1) {
if (this.i === this.container.size() - 1) {
throwIteratorAccessError();

@@ -82,12 +79,6 @@ }

get pointer() {
if (this.i < 0 || this.i > this.o() - 1) {
throw new RangeError;
}
return this.u(this.i);
return this.container.getElementByPos(this.i);
}
set pointer(t) {
if (this.i < 0 || this.i > this.o() - 1) {
throw new RangeError;
}
this.l(this.i, t);
this.container.setElementByPos(this.i, t);
}

@@ -97,4 +88,8 @@ }

class VectorIterator extends RandomIterator {
constructor(t, r, e) {
super(t, e);
this.container = r;
}
copy() {
return new VectorIterator(this.i, this.o, this.u, this.l, this.iteratorType);
return new VectorIterator(this.i, this.container, this.iteratorType);
}

@@ -107,6 +102,6 @@ }

if (Array.isArray(t)) {
this.I = r ? [ ...t ] : t;
this.o = r ? [ ...t ] : t;
this.h = t.length;
} else {
this.I = [];
this.o = [];
const r = this;

@@ -117,27 +112,24 @@ t.forEach((function(t) {

}
this.size = this.size.bind(this);
this.getElementByPos = this.getElementByPos.bind(this);
this.setElementByPos = this.setElementByPos.bind(this);
}
clear() {
this.h = 0;
this.I.length = 0;
this.o.length = 0;
}
begin() {
return new VectorIterator(0, this.size, this.getElementByPos, this.setElementByPos);
return new VectorIterator(0, this);
}
end() {
return new VectorIterator(this.h, this.size, this.getElementByPos, this.setElementByPos);
return new VectorIterator(this.h, this);
}
rBegin() {
return new VectorIterator(this.h - 1, this.size, this.getElementByPos, this.setElementByPos, 1);
return new VectorIterator(this.h - 1, this, 1);
}
rEnd() {
return new VectorIterator(-1, this.size, this.getElementByPos, this.setElementByPos, 1);
return new VectorIterator(-1, this, 1);
}
front() {
return this.I[0];
return this.o[0];
}
back() {
return this.I[this.h - 1];
return this.o[this.h - 1];
}

@@ -148,3 +140,3 @@ getElementByPos(t) {

}
return this.I[t];
return this.o[t];
}

@@ -155,3 +147,3 @@ eraseElementByPos(t) {

}
this.I.splice(t, 1);
this.o.splice(t, 1);
this.h -= 1;

@@ -162,8 +154,8 @@ return this.h;

let r = 0;
for (let s = 0; s < this.h; ++s) {
if (this.I[s] !== t) {
this.I[r++] = this.I[s];
for (let e = 0; e < this.h; ++e) {
if (this.o[e] !== t) {
this.o[r++] = this.o[e];
}
}
this.h = this.I.length = r;
this.h = this.o.length = r;
return this.h;

@@ -178,3 +170,3 @@ }

pushBack(t) {
this.I.push(t);
this.o.push(t);
this.h += 1;

@@ -186,3 +178,3 @@ return this.h;

this.h -= 1;
return this.I.pop();
return this.o.pop();
}

@@ -193,10 +185,10 @@ setElementByPos(t, r) {

}
this.I[t] = r;
this.o[t] = r;
}
insert(t, r, s = 1) {
insert(t, r, e = 1) {
if (t < 0 || t > this.h) {
throw new RangeError;
}
this.I.splice(t, 0, ...new Array(s).fill(r));
this.h += s;
this.o.splice(t, 0, ...new Array(e).fill(r));
this.h += e;
return this.h;

@@ -206,4 +198,4 @@ }

for (let r = 0; r < this.h; ++r) {
if (this.I[r] === t) {
return new VectorIterator(r, this.size, this.getElementByPos, this.getElementByPos);
if (this.o[r] === t) {
return new VectorIterator(r, this);
}

@@ -214,3 +206,3 @@ }

reverse() {
this.I.reverse();
this.o.reverse();
}

@@ -220,15 +212,15 @@ unique() {

for (let r = 1; r < this.h; ++r) {
if (this.I[r] !== this.I[r - 1]) {
this.I[t++] = this.I[r];
if (this.o[r] !== this.o[r - 1]) {
this.o[t++] = this.o[r];
}
}
this.h = this.I.length = t;
this.h = this.o.length = t;
return this.h;
}
sort(t) {
this.I.sort(t);
this.o.sort(t);
}
forEach(t) {
for (let r = 0; r < this.h; ++r) {
t(this.I[r], r, this);
t(this.o[r], r, this);
}

@@ -238,3 +230,3 @@ }

return function*() {
yield* this.I;
yield* this.o;
}.bind(this)();

@@ -241,0 +233,0 @@ }

@@ -10,2 +10,6 @@ /**

/**
* @description The container pointed to by the iterator.
*/
abstract readonly container: Container<T>;
/**
* @description Iterator's type.

@@ -199,10 +203,6 @@ * @example

*/
type initContainer<T> = ({
size: number;
} | {
length: number;
} | {
size(): number;
}) & {
forEach(callback: (element: T) => void): void;
type initContainer<T> = {
size?: number | (() => number);
length?: number;
forEach: (callback: (el: T) => void) => void;
};

@@ -275,2 +275,3 @@ declare abstract class SequentialContainer<T> extends Container<T> {

declare abstract class RandomIterator<T> extends ContainerIterator<T> {
abstract readonly container: SequentialContainer<T>;
get pointer(): T;

@@ -284,2 +285,4 @@ set pointer(newValue: T);

declare class VectorIterator<T> extends RandomIterator<T> {
container: Vector<T>;
constructor(node: number, container: Vector<T>, iteratorType?: IteratorType);
copy(): VectorIterator<T>;

@@ -286,0 +289,0 @@ // @ts-ignore

@@ -211,10 +211,7 @@ var extendStatics = function(t, r) {

__extends(RandomIterator, t);
function RandomIterator(r, n, e, i, o) {
var s = t.call(this, o) || this;
s.t = r;
s.o = n;
s.u = e;
s.h = i;
if (s.iteratorType === 0) {
s.pre = function() {
function RandomIterator(r, n) {
var e = t.call(this, n) || this;
e.t = r;
if (e.iteratorType === 0) {
e.pre = function() {
if (this.t === 0) {

@@ -226,4 +223,4 @@ throwIteratorAccessError();

};
s.next = function() {
if (this.t === this.o()) {
e.next = function() {
if (this.t === this.container.size()) {
throwIteratorAccessError();

@@ -235,4 +232,4 @@ }

} else {
s.pre = function() {
if (this.t === this.o() - 1) {
e.pre = function() {
if (this.t === this.container.size() - 1) {
throwIteratorAccessError();

@@ -243,3 +240,3 @@ }

};
s.next = function() {
e.next = function() {
if (this.t === -1) {

@@ -252,16 +249,10 @@ throwIteratorAccessError();

}
return s;
return e;
}
Object.defineProperty(RandomIterator.prototype, "pointer", {
get: function() {
if (this.t < 0 || this.t > this.o() - 1) {
throw new RangeError;
}
return this.u(this.t);
return this.container.getElementByPos(this.t);
},
set: function(t) {
if (this.t < 0 || this.t > this.o() - 1) {
throw new RangeError;
}
this.h(this.t, t);
this.container.setElementByPos(this.t, t);
},

@@ -276,7 +267,9 @@ enumerable: false,

__extends(VectorIterator, t);
function VectorIterator() {
return t !== null && t.apply(this, arguments) || this;
function VectorIterator(r, n, e) {
var i = t.call(this, r, e) || this;
i.container = n;
return i;
}
VectorIterator.prototype.copy = function() {
return new VectorIterator(this.t, this.o, this.u, this.h, this.iteratorType);
return new VectorIterator(this.t, this.container, this.iteratorType);
};

@@ -297,6 +290,6 @@ return VectorIterator;

if (Array.isArray(r)) {
e.l = n ? __spreadArray([], __read(r), false) : r;
e.o = n ? __spreadArray([], __read(r), false) : r;
e.i = r.length;
} else {
e.l = [];
e.o = [];
var i = e;

@@ -307,5 +300,2 @@ r.forEach((function(t) {

}
e.size = e.size.bind(e);
e.getElementByPos = e.getElementByPos.bind(e);
e.setElementByPos = e.setElementByPos.bind(e);
return e;

@@ -315,21 +305,21 @@ }

this.i = 0;
this.l.length = 0;
this.o.length = 0;
};
Vector.prototype.begin = function() {
return new VectorIterator(0, this.size, this.getElementByPos, this.setElementByPos);
return new VectorIterator(0, this);
};
Vector.prototype.end = function() {
return new VectorIterator(this.i, this.size, this.getElementByPos, this.setElementByPos);
return new VectorIterator(this.i, this);
};
Vector.prototype.rBegin = function() {
return new VectorIterator(this.i - 1, this.size, this.getElementByPos, this.setElementByPos, 1);
return new VectorIterator(this.i - 1, this, 1);
};
Vector.prototype.rEnd = function() {
return new VectorIterator(-1, this.size, this.getElementByPos, this.setElementByPos, 1);
return new VectorIterator(-1, this, 1);
};
Vector.prototype.front = function() {
return this.l[0];
return this.o[0];
};
Vector.prototype.back = function() {
return this.l[this.i - 1];
return this.o[this.i - 1];
};

@@ -340,3 +330,3 @@ Vector.prototype.getElementByPos = function(t) {

}
return this.l[t];
return this.o[t];
};

@@ -347,3 +337,3 @@ Vector.prototype.eraseElementByPos = function(t) {

}
this.l.splice(t, 1);
this.o.splice(t, 1);
this.i -= 1;

@@ -355,7 +345,7 @@ return this.i;

for (var n = 0; n < this.i; ++n) {
if (this.l[n] !== t) {
this.l[r++] = this.l[n];
if (this.o[n] !== t) {
this.o[r++] = this.o[n];
}
}
this.i = this.l.length = r;
this.i = this.o.length = r;
return this.i;

@@ -370,3 +360,3 @@ };

Vector.prototype.pushBack = function(t) {
this.l.push(t);
this.o.push(t);
this.i += 1;

@@ -378,3 +368,3 @@ return this.i;

this.i -= 1;
return this.l.pop();
return this.o.pop();
};

@@ -385,3 +375,3 @@ Vector.prototype.setElementByPos = function(t, r) {

}
this.l[t] = r;
this.o[t] = r;
};

@@ -396,3 +386,3 @@ Vector.prototype.insert = function(t, r, n) {

}
(e = this.l).splice.apply(e, __spreadArray([ t, 0 ], __read(new Array(n).fill(r)), false));
(e = this.o).splice.apply(e, __spreadArray([ t, 0 ], __read(new Array(n).fill(r)), false));
this.i += n;

@@ -403,4 +393,4 @@ return this.i;

for (var r = 0; r < this.i; ++r) {
if (this.l[r] === t) {
return new VectorIterator(r, this.size, this.getElementByPos, this.getElementByPos);
if (this.o[r] === t) {
return new VectorIterator(r, this);
}

@@ -411,3 +401,3 @@ }

Vector.prototype.reverse = function() {
this.l.reverse();
this.o.reverse();
};

@@ -417,15 +407,15 @@ Vector.prototype.unique = function() {

for (var r = 1; r < this.i; ++r) {
if (this.l[r] !== this.l[r - 1]) {
this.l[t++] = this.l[r];
if (this.o[r] !== this.o[r - 1]) {
this.o[t++] = this.o[r];
}
}
this.i = this.l.length = t;
this.i = this.o.length = t;
return this.i;
};
Vector.prototype.sort = function(t) {
this.l.sort(t);
this.o.sort(t);
};
Vector.prototype.forEach = function(t) {
for (var r = 0; r < this.i; ++r) {
t(this.l[r], r, this);
t(this.o[r], r, this);
}

@@ -438,3 +428,3 @@ };

case 0:
return [ 5, __values(this.l) ];
return [ 5, __values(this.o) ];

@@ -441,0 +431,0 @@ case 1:

/*!
* @js-sdsl/vector v4.2.0
* @js-sdsl/vector v4.3.0
* https://github.com/js-sdsl/js-sdsl

@@ -275,8 +275,5 @@ * (c) 2021-present ZLY201 <zilongyao1366@gmail.com>

*/
function RandomIterator(index, size, getElementByPos, setElementByPos, iteratorType) {
function RandomIterator(index, iteratorType) {
var _this = _super.call(this, iteratorType) || this;
_this._node = index;
_this._size = size;
_this._getElementByPos = getElementByPos;
_this._setElementByPos = setElementByPos;
if (_this.iteratorType === 0 /* IteratorType.NORMAL */) {

@@ -291,3 +288,3 @@ _this.pre = function () {

_this.next = function () {
if (this._node === this._size()) {
if (this._node === this.container.size()) {
throwIteratorAccessError();

@@ -300,3 +297,3 @@ }

_this.pre = function () {
if (this._node === this._size() - 1) {
if (this._node === this.container.size() - 1) {
throwIteratorAccessError();

@@ -319,16 +316,6 @@ }

get: function () {
if (this._node < 0 || this._node > this._size() - 1) {
throw new RangeError();
} /**
* @internal
*/
return this._getElementByPos(this._node);
return this.container.getElementByPos(this._node);
},
set: function (newValue) {
if (this._node < 0 || this._node > this._size() - 1) {
throw new RangeError();
} /**
* @internal
*/
this._setElementByPos(this._node, newValue);
this.container.setElementByPos(this._node, newValue);
},

@@ -343,7 +330,9 @@ enumerable: false,

__extends(VectorIterator, _super);
function VectorIterator() {
return _super !== null && _super.apply(this, arguments) || this;
function VectorIterator(node, container, iteratorType) {
var _this = _super.call(this, node, iteratorType) || this;
_this.container = container;
return _this;
}
VectorIterator.prototype.copy = function () {
return new VectorIterator(this._node, this._size, this._getElementByPos, this._setElementByPos, this.iteratorType);
return new VectorIterator(this._node, this.container, this.iteratorType);
};

@@ -377,5 +366,2 @@ return VectorIterator;

}
_this.size = _this.size.bind(_this);
_this.getElementByPos = _this.getElementByPos.bind(_this);
_this.setElementByPos = _this.setElementByPos.bind(_this);
return _this;

@@ -388,13 +374,13 @@ }

Vector.prototype.begin = function () {
return new VectorIterator(0, this.size, this.getElementByPos, this.setElementByPos);
return new VectorIterator(0, this);
};
Vector.prototype.end = function () {
return new VectorIterator(this._length, this.size, this.getElementByPos, this.setElementByPos);
return new VectorIterator(this._length, this);
};
Vector.prototype.rBegin = function () {
return new VectorIterator(this._length - 1, this.size, this.getElementByPos, this.setElementByPos, 1 /* IteratorType.REVERSE */);
return new VectorIterator(this._length - 1, this, 1 /* IteratorType.REVERSE */);
};
Vector.prototype.rEnd = function () {
return new VectorIterator(-1, this.size, this.getElementByPos, this.setElementByPos, 1 /* IteratorType.REVERSE */);
return new VectorIterator(-1, this, 1 /* IteratorType.REVERSE */);
};

@@ -469,3 +455,3 @@

if (this._vector[i] === element) {
return new VectorIterator(i, this.size, this.getElementByPos, this.getElementByPos);
return new VectorIterator(i, this);
}

@@ -472,0 +458,0 @@ }

/*!
* @js-sdsl/vector v4.2.0
* @js-sdsl/vector v4.3.0
* https://github.com/js-sdsl/js-sdsl

@@ -7,3 +7,3 @@ * (c) 2021-present ZLY201 <zilongyao1366@gmail.com>

*/
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).sdsl={})}(this,function(t){"use strict";var r=function(t,e){return(r=Object.setPrototypeOf||({__proto__:[]}instanceof Array?function(t,e){t.__proto__=e}:function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])}))(t,e)};function e(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}function n(r,i){var o,s,l,u={label:0,sent:function(){if(1&l[0])throw l[1];return l[1]},trys:[],ops:[]},h={next:t(0),throw:t(1),return:t(2)};return"function"==typeof Symbol&&(h[Symbol.iterator]=function(){return this}),h;function t(n){return function(t){var e=[n,t];if(o)throw new TypeError("Generator is already executing.");for(;u=h&&e[h=0]?0:u;)try{if(o=1,s&&(l=2&e[0]?s.return:e[0]?s.throw||((l=s.return)&&l.call(s),0):s.next)&&!(l=l.call(s,e[1])).done)return l;switch(s=0,(e=l?[2&e[0],l.value]:e)[0]){case 0:case 1:l=e;break;case 4:return u.label++,{value:e[1],done:!1};case 5:u.label++,s=e[1],e=[0];continue;case 7:e=u.ops.pop(),u.trys.pop();continue;default:if(!(l=0<(l=u.trys).length&&l[l.length-1])&&(6===e[0]||2===e[0])){u=0;continue}if(3===e[0]&&(!l||e[1]>l[0]&&e[1]<l[3]))u.label=e[1];else if(6===e[0]&&u.label<l[1])u.label=l[1],l=e;else{if(!(l&&u.label<l[2])){l[2]&&u.ops.pop(),u.trys.pop();continue}u.label=l[2],u.ops.push(e)}}e=i.call(r,u)}catch(t){e=[6,t],s=0}finally{o=l=0}if(5&e[0])throw e[1];return{value:e[0]?e[1]:void 0,done:!0}}}}function i(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,i,o=n.call(t),s=[];try{for(;(void 0===e||0<e--)&&!(r=o.next()).done;)s.push(r.value)}catch(t){i={error:t}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return s}function o(t,e,n){if(n||2===arguments.length)for(var r,i=0,o=e.length;i<o;i++)!r&&i in e||((r=r||Array.prototype.slice.call(e,0,i))[i]=e[i]);return t.concat(r||Array.prototype.slice.call(e))}l.prototype.equals=function(t){return this.t===t.t};var s=l;function l(t){this.iteratorType=t=void 0===t?0:t}function u(){this.i=0}Object.defineProperty(u.prototype,"length",{get:function(){return this.i},enumerable:!1,configurable:!0}),u.prototype.size=function(){return this.i},u.prototype.empty=function(){return 0===this.i};e(p,h=u);var h,c=p;function p(){return null!==h&&h.apply(this,arguments)||this}e(a,f=c);var f,c=a;function a(){return null!==f&&f.apply(this,arguments)||this}function y(){throw new RangeError("Iterator access denied!")}e(b,d=s),Object.defineProperty(b.prototype,"pointer",{get:function(){if(this.t<0||this.t>this.o()-1)throw new RangeError;return this.u(this.t)},set:function(t){if(this.t<0||this.t>this.o()-1)throw new RangeError;this.h(this.t,t)},enumerable:!1,configurable:!0});var d,s=b;function b(t,e,n,r,i){i=d.call(this,i)||this;return i.t=t,i.o=e,i.u=n,i.h=r,0===i.iteratorType?(i.pre=function(){return 0===this.t&&y(),--this.t,this},i.next=function(){return this.t===this.o()&&y(),this.t+=1,this}):(i.pre=function(){return this.t===this.o()-1&&y(),this.t+=1,this},i.next=function(){return-1===this.t&&y(),--this.t,this}),i}e(w,g=s),w.prototype.copy=function(){return new w(this.t,this.o,this.u,this.h,this.iteratorType)};var g,v=w;function w(){return null!==g&&g.apply(this,arguments)||this}e(E,m=c),E.prototype.clear=function(){this.i=0,this.l.length=0},E.prototype.begin=function(){return new v(0,this.size,this.getElementByPos,this.setElementByPos)},E.prototype.end=function(){return new v(this.i,this.size,this.getElementByPos,this.setElementByPos)},E.prototype.rBegin=function(){return new v(this.i-1,this.size,this.getElementByPos,this.setElementByPos,1)},E.prototype.rEnd=function(){return new v(-1,this.size,this.getElementByPos,this.setElementByPos,1)},E.prototype.front=function(){return this.l[0]},E.prototype.back=function(){return this.l[this.i-1]},E.prototype.getElementByPos=function(t){if(t<0||t>this.i-1)throw new RangeError;return this.l[t]},E.prototype.eraseElementByPos=function(t){if(t<0||t>this.i-1)throw new RangeError;return this.l.splice(t,1),--this.i,this.i},E.prototype.eraseElementByValue=function(t){for(var e=0,n=0;n<this.i;++n)this.l[n]!==t&&(this.l[e++]=this.l[n]);return this.i=this.l.length=e,this.i},E.prototype.eraseElementByIterator=function(t){var e=t.t;return t=t.next(),this.eraseElementByPos(e),t},E.prototype.pushBack=function(t){return this.l.push(t),this.i+=1,this.i},E.prototype.popBack=function(){if(0!==this.i)return--this.i,this.l.pop()},E.prototype.setElementByPos=function(t,e){if(t<0||t>this.i-1)throw new RangeError;this.l[t]=e},E.prototype.insert=function(t,e,n){var r;if(void 0===n&&(n=1),t<0||t>this.i)throw new RangeError;return(r=this.l).splice.apply(r,o([t,0],i(new Array(n).fill(e)),!1)),this.i+=n,this.i},E.prototype.find=function(t){for(var e=0;e<this.i;++e)if(this.l[e]===t)return new v(e,this.size,this.getElementByPos,this.getElementByPos);return this.end()},E.prototype.reverse=function(){this.l.reverse()},E.prototype.unique=function(){for(var t=1,e=1;e<this.i;++e)this.l[e]!==this.l[e-1]&&(this.l[t++]=this.l[e]);return this.i=this.l.length=t,this.i},E.prototype.sort=function(t){this.l.sort(t)},E.prototype.forEach=function(t){for(var e=0;e<this.i;++e)t(this.l[e],e,this)},E.prototype[Symbol.iterator]=function(){return function(){return n(this,function(t){switch(t.label){case 0:return[5,function(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return{value:(t=t&&r>=t.length?void 0:t)&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}(this.l)];case 1:return t.sent(),[2]}})}.bind(this)()};var m,s=E;function E(t,e){void 0===t&&(t=[]),void 0===e&&(e=!0);var n,r=m.call(this)||this;return Array.isArray(t)?(r.l=e?o([],i(t),!1):t,r.i=t.length):(r.l=[],n=r,t.forEach(function(t){n.pushBack(t)})),r.size=r.size.bind(r),r.getElementByPos=r.getElementByPos.bind(r),r.setElementByPos=r.setElementByPos.bind(r),r}t.Vector=s,Object.defineProperty(t,"_",{value:!0})});
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).sdsl={})}(this,function(t){"use strict";var n=function(t,e){return(n=Object.setPrototypeOf||({__proto__:[]}instanceof Array?function(t,e){t.__proto__=e}:function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])}))(t,e)};function e(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}function r(n,o){var i,s,u,h={label:0,sent:function(){if(1&u[0])throw u[1];return u[1]},trys:[],ops:[]},c={next:t(0),throw:t(1),return:t(2)};return"function"==typeof Symbol&&(c[Symbol.iterator]=function(){return this}),c;function t(r){return function(t){var e=[r,t];if(i)throw new TypeError("Generator is already executing.");for(;h=c&&e[c=0]?0:h;)try{if(i=1,s&&(u=2&e[0]?s.return:e[0]?s.throw||((u=s.return)&&u.call(s),0):s.next)&&!(u=u.call(s,e[1])).done)return u;switch(s=0,(e=u?[2&e[0],u.value]:e)[0]){case 0:case 1:u=e;break;case 4:return h.label++,{value:e[1],done:!1};case 5:h.label++,s=e[1],e=[0];continue;case 7:e=h.ops.pop(),h.trys.pop();continue;default:if(!(u=0<(u=h.trys).length&&u[u.length-1])&&(6===e[0]||2===e[0])){h=0;continue}if(3===e[0]&&(!u||e[1]>u[0]&&e[1]<u[3]))h.label=e[1];else if(6===e[0]&&h.label<u[1])h.label=u[1],u=e;else{if(!(u&&h.label<u[2])){u[2]&&h.ops.pop(),h.trys.pop();continue}h.label=u[2],h.ops.push(e)}}e=o.call(n,h)}catch(t){e=[6,t],s=0}finally{i=u=0}if(5&e[0])throw e[1];return{value:e[0]?e[1]:void 0,done:!0}}}}function o(t,e){var r="function"==typeof Symbol&&t[Symbol.iterator];if(!r)return t;var n,o,i=r.call(t),s=[];try{for(;(void 0===e||0<e--)&&!(n=i.next()).done;)s.push(n.value)}catch(t){o={error:t}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(o)throw o.error}}return s}function i(t,e,r){if(r||2===arguments.length)for(var n,o=0,i=e.length;o<i;o++)!n&&o in e||((n=n||Array.prototype.slice.call(e,0,o))[o]=e[o]);return t.concat(n||Array.prototype.slice.call(e))}u.prototype.equals=function(t){return this.t===t.t};var s=u;function u(t){this.iteratorType=t=void 0===t?0:t}function h(){this.i=0}Object.defineProperty(h.prototype,"length",{get:function(){return this.i},enumerable:!1,configurable:!0}),h.prototype.size=function(){return this.i},h.prototype.empty=function(){return 0===this.i};e(a,c=h);var c,p=a;function a(){return null!==c&&c.apply(this,arguments)||this}e(l,f=p);var f,p=l;function l(){return null!==f&&f.apply(this,arguments)||this}function y(){throw new RangeError("Iterator access denied!")}e(b,d=s),Object.defineProperty(b.prototype,"pointer",{get:function(){return this.container.getElementByPos(this.t)},set:function(t){this.container.setElementByPos(this.t,t)},enumerable:!1,configurable:!0});var d,s=b;function b(t,e){e=d.call(this,e)||this;return e.t=t,0===e.iteratorType?(e.pre=function(){return 0===this.t&&y(),--this.t,this},e.next=function(){return this.t===this.container.size()&&y(),this.t+=1,this}):(e.pre=function(){return this.t===this.container.size()-1&&y(),this.t+=1,this},e.next=function(){return-1===this.t&&y(),--this.t,this}),e}e(g,v=s),g.prototype.copy=function(){return new g(this.t,this.container,this.iteratorType)};var v,w=g;function g(t,e,r){t=v.call(this,t,r)||this;return t.container=e,t}e(E,m=p),E.prototype.clear=function(){this.i=0,this.o.length=0},E.prototype.begin=function(){return new w(0,this)},E.prototype.end=function(){return new w(this.i,this)},E.prototype.rBegin=function(){return new w(this.i-1,this,1)},E.prototype.rEnd=function(){return new w(-1,this,1)},E.prototype.front=function(){return this.o[0]},E.prototype.back=function(){return this.o[this.i-1]},E.prototype.getElementByPos=function(t){if(t<0||t>this.i-1)throw new RangeError;return this.o[t]},E.prototype.eraseElementByPos=function(t){if(t<0||t>this.i-1)throw new RangeError;return this.o.splice(t,1),--this.i,this.i},E.prototype.eraseElementByValue=function(t){for(var e=0,r=0;r<this.i;++r)this.o[r]!==t&&(this.o[e++]=this.o[r]);return this.i=this.o.length=e,this.i},E.prototype.eraseElementByIterator=function(t){var e=t.t;return t=t.next(),this.eraseElementByPos(e),t},E.prototype.pushBack=function(t){return this.o.push(t),this.i+=1,this.i},E.prototype.popBack=function(){if(0!==this.i)return--this.i,this.o.pop()},E.prototype.setElementByPos=function(t,e){if(t<0||t>this.i-1)throw new RangeError;this.o[t]=e},E.prototype.insert=function(t,e,r){var n;if(void 0===r&&(r=1),t<0||t>this.i)throw new RangeError;return(n=this.o).splice.apply(n,i([t,0],o(new Array(r).fill(e)),!1)),this.i+=r,this.i},E.prototype.find=function(t){for(var e=0;e<this.i;++e)if(this.o[e]===t)return new w(e,this);return this.end()},E.prototype.reverse=function(){this.o.reverse()},E.prototype.unique=function(){for(var t=1,e=1;e<this.i;++e)this.o[e]!==this.o[e-1]&&(this.o[t++]=this.o[e]);return this.i=this.o.length=t,this.i},E.prototype.sort=function(t){this.o.sort(t)},E.prototype.forEach=function(t){for(var e=0;e<this.i;++e)t(this.o[e],e,this)},E.prototype[Symbol.iterator]=function(){return function(){return r(this,function(t){switch(t.label){case 0:return[5,function(t){var e="function"==typeof Symbol&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&"number"==typeof t.length)return{next:function(){return{value:(t=t&&n>=t.length?void 0:t)&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}(this.o)];case 1:return t.sent(),[2]}})}.bind(this)()};var m,s=E;function E(t,e){void 0===t&&(t=[]),void 0===e&&(e=!0);var r,n=m.call(this)||this;return Array.isArray(t)?(n.o=e?i([],o(t),!1):t,n.i=t.length):(n.o=[],r=n,t.forEach(function(t){r.pushBack(t)})),n}t.Vector=s,Object.defineProperty(t,"u",{value:!0})});
//# sourceMappingURL=vector.min.js.map
{
"name": "@js-sdsl/vector",
"version": "4.2.0",
"version": "4.3.0",
"description": "javascript standard data structure library which benchmark against C++ STL",

@@ -5,0 +5,0 @@ "main": "./dist/cjs/index.js",

@@ -11,3 +11,3 @@ <p align="center">

<a href="https://www.npmjs.com/package/js-sdsl"><img src="https://img.shields.io/npm/v/js-sdsl.svg" alt="NPM Version" /></a>
<a href="https://github.com/js-sdsl/js-sdsl/actions/workflows/build.yml"><img src="https://img.shields.io/github/workflow/status/js-sdsl/js-sdsl/js-sdsl%20CI" alt="Build Status" /></a>
<a href="https://github.com/js-sdsl/js-sdsl/actions/workflows/build.yml"><img src="https://img.shields.io/github/actions/workflow/status/js-sdsl/js-sdsl/build.yml" alt="Build Status" /></a>
<a href='https://coveralls.io/github/js-sdsl/js-sdsl?branch=main'><img src='https://coveralls.io/repos/github/js-sdsl/js-sdsl/badge.svg?branch=main' alt='Coverage Status' /></a>

@@ -26,4 +26,4 @@ <a href="https://github.com/js-sdsl/js-sdsl"><img src="https://img.shields.io/github/stars/js-sdsl/js-sdsl.svg" alt="GITHUB Star" /></a>

- **Stack** - first in first out stack.
- **Queue** - first in last out queue.
- **Stack** - first in last out stack.
- **Queue** - first in first out queue.
- **PriorityQueue** - heap-implemented priority queue.

@@ -162,3 +162,3 @@ - **Vector** - protected array, cannot to operate properties like `length` directly.

We use jest library to write unit tests, you can see test coverage on [coveralls](https://coveralls.io/github/js-sdsl/js-sdsl). You can run `yarn test:unit` command to reproduce it.
We use [karma](https://karma-runner.github.io/) and [mocha](https://mochajs.org/) frame to do unit tests and synchronize to [coveralls](https://coveralls.io/github/js-sdsl/js-sdsl). You can run `yarn test:unit` command to reproduce it.

@@ -180,3 +180,3 @@ ### For performance

```bash
$ git clone https://github.com/js-sdsl/js-sdl.git
$ git clone https://github.com/js-sdsl/js-sdsl.git
$ cd js-sdsl

@@ -183,0 +183,0 @@ $ npm install

@@ -11,3 +11,3 @@ <p align="center">

<a href="https://www.npmjs.com/package/js-sdsl"><img src="https://img.shields.io/npm/v/js-sdsl.svg" alt="NPM Version" /></a>
<a href="https://github.com/js-sdsl/js-sdsl/actions/workflows/build.yml"><img src="https://img.shields.io/github/workflow/status/js-sdsl/js-sdsl/js-sdsl%20CI" alt="Build Status" /></a>
<a href="https://github.com/js-sdsl/js-sdsl/actions/workflows/build.yml"><img src="https://img.shields.io/github/actions/workflow/status/js-sdsl/js-sdsl/build.yml" alt="Build Status" /></a>
<a href='https://coveralls.io/github/js-sdsl/js-sdsl?branch=main'><img src='https://coveralls.io/repos/github/js-sdsl/js-sdsl/badge.svg?branch=main' alt='Coverage Status' /></a>

@@ -26,4 +26,4 @@ <a href="https://github.com/js-sdsl/js-sdsl"><img src="https://img.shields.io/github/stars/js-sdsl/js-sdsl.svg" alt="GITHUB Star" /></a>

- **Stack** - 先进先出的堆栈
- **Queue** - 先进后出的队列
- **Stack** - 先进后出的堆栈
- **Queue** - 先进先出的队列
- **PriorityQueue** - 堆实现的优先级队列

@@ -164,3 +164,3 @@ - **Vector** - 受保护的数组,不能直接操作像 `length` 这样的属性

我们使用 `jest` 库来编写我们的单元测试,并将结果同步到了 [coveralls](https://coveralls.io/github/js-sdsl/js-sdsl) 上,你可以使用 `yarn test:unit` 命令来重建它
我们使用 [karma](https://karma-runner.github.io/) 和 [mocha](https://mochajs.org/) 框架进行单元测试,并同步到 [coveralls](https://coveralls.io/github/js-sdsl/js-sdsl) 上,你可以使用 `yarn test:unit` 命令来重建它

@@ -182,3 +182,3 @@ ### 对于性能的校验

```bash
$ git clone https://github.com/js-sdsl/js-sdl.git
$ git clone https://github.com/js-sdsl/js-sdsl.git
$ cd js-sdsl

@@ -185,0 +185,0 @@ $ npm install

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc