Socket
Socket
Sign inDemoInstall

@js-sdsl/link-list

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/link-list - npm Package Compare versions

Comparing version 4.2.0-beta.1 to 4.2.0

22

CHANGELOG.md

@@ -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 @@

170

dist/cjs/index.d.ts

@@ -0,1 +1,4 @@

/**
* @description The iterator type including `NORMAL` and `REVERSE`.
*/
declare const enum IteratorType {

@@ -8,10 +11,18 @@ NORMAL = 0,

* @description Iterator's type.
* @example console.log(container.end().iteratorType === IteratorType.NORMAL); // true
* @example
* console.log(container.end().iteratorType === IteratorType.NORMAL); // true
*/
readonly iteratorType: IteratorType;
protected constructor(iteratorType?: IteratorType);
/**
* @param iter - The other iterator you want to compare.
* @returns Whether this equals to obj.
* @example
* container.find(1).equals(container.end());
*/
equals(iter: ContainerIterator<T>): boolean;
/**
* @description Pointers to element.
* @return The value of the pointer's element.
* @example const val = container.begin().pointer;
* @returns The value of the pointer's element.
* @example
* const val = container.begin().pointer;
*/

@@ -21,4 +32,5 @@ abstract get pointer(): T;

* @description Set pointer's value (some containers are unavailable).
* @param newValue The new value you want to set.
* @example (<LinkList<number>>container).begin().pointer = 1;
* @param newValue - The new value you want to set.
* @example
* (<LinkList<number>>container).begin().pointer = 1;
*/

@@ -28,2 +40,3 @@ abstract set pointer(newValue: T);

* @description Move `this` iterator to pre.
* @returns The iterator's self.
* @example

@@ -39,2 +52,3 @@ * const iter = container.find(1); // container = [0, 1]

* @description Move `this` iterator to next.
* @returns The iterator's self.
* @example

@@ -49,10 +63,4 @@ * const iter = container.find(1); // container = [1, 2]

/**
* @param obj The other iterator you want to compare.
* @return Boolean about if this equals to obj.
* @example container.find(1).equals(container.end());
*/
abstract equals(obj: ContainerIterator<T>): boolean;
/**
* @description Get a copy of itself.
* @return The copy of self.
* @returns The copy of self.
* @example

@@ -69,5 +77,12 @@ * const iter = container.find(1); // container = [1, 2]

/**
* @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

@@ -77,3 +92,3 @@ */

/**
* @return Boolean about if the container is empty.
* @returns Whether the container is empty.
* @example

@@ -94,3 +109,3 @@ * container.clear();

/**
* @return Iterator pointing to the beginning element.
* @returns Iterator pointing to the beginning element.
* @example

@@ -105,3 +120,3 @@ * const begin = container.begin();

/**
* @return Iterator pointing to the super end like c++.
* @returns Iterator pointing to the super end like c++.
* @example

@@ -116,3 +131,3 @@ * const begin = container.begin();

/**
* @return Iterator pointing to the end element.
* @returns Iterator pointing to the end element.
* @example

@@ -127,3 +142,3 @@ * const rBegin = container.rBegin();

/**
* @return Iterator pointing to the super begin like c++.
* @returns Iterator pointing to the super begin like c++.
* @example

@@ -138,22 +153,24 @@ * const rBegin = container.rBegin();

/**
* @return The first element of the container.
* @returns The first element of the container.
*/
abstract front(): T | undefined;
/**
* @return The last element of the container.
* @returns The last element of the container.
*/
abstract back(): T | undefined;
/**
* @param element - The element you want to find.
* @returns An iterator pointing to the element if found, or super end if not found.
* @example
* container.find(1).equals(container.end());
*/
abstract find(element: T): ContainerIterator<T>;
/**
* @description Iterate over all elements in the container.
* @param callback Callback function like Array.forEach.
* @example container.forEach((element, index) => console.log(element, index));
* @param callback - Callback function like Array.forEach.
* @example
* container.forEach((element, index) => console.log(element, index));
*/
abstract forEach(callback: (element: T, index: number, container: Container<T>) => void): void;
/**
* @param element The element you want to find.
* @return An iterator pointing to the element if found, or super end if not found.
* @example container.find(1).equals(container.end());
*/
abstract find(element: T): ContainerIterator<T>;
/**
* @description Gets the value of the element at the specified position.

@@ -166,9 +183,12 @@ * @example

* @description Removes the element at the specified position.
* @param pos The element's position you want to remove.
* @param pos - The element's position you want to remove.
* @returns The container length after erasing.
* @example
* container.eraseElementByPos(-1); // throw a RangeError
*/
abstract eraseElementByPos(pos: number): void;
abstract eraseElementByPos(pos: number): number;
/**
* @description Removes element by iterator and move `iter` to next.
* @param iter The iterator you want to erase.
* @param iter - The iterator you want to erase.
* @returns The next iterator.
* @example

@@ -186,4 +206,7 @@ * container.eraseElementByIterator(container.begin());

*/
abstract [Symbol.iterator](): Generator<T, void, undefined>;
abstract [Symbol.iterator](): Generator<T, void>;
}
/**
* @description The initial data type passed in when initializing the container.
*/
type initContainer<T> = ({

@@ -201,14 +224,17 @@ size: number;

* @description Push the element to the back.
* @param element The element you want to push.
* @param element - The element you want to push.
* @returns The size of container after pushing.
*/
abstract pushBack(element: T): void;
abstract pushBack(element: T): number;
/**
* @description Removes the last element.
* @returns The element you popped.
*/
abstract popBack(): void;
abstract popBack(): T | undefined;
/**
* @description Sets element by position.
* @param pos The position you want to change.
* @param element The element's value you want to update.
* @example container.setElementByPos(-1, 1); // throw a RangeError
* @param pos - The position you want to change.
* @param element - The element's value you want to update.
* @example
* container.setElementByPos(-1, 1); // throw a RangeError
*/

@@ -218,11 +244,14 @@ abstract setElementByPos(pos: number, element: T): void;

* @description Removes the elements of the specified value.
* @param value The value you want to remove.
* @example container.eraseElementByValue(-1);
* @param value - The value you want to remove.
* @returns The size of container after erasing.
* @example
* container.eraseElementByValue(-1);
*/
abstract eraseElementByValue(value: T): void;
abstract eraseElementByValue(value: T): number;
/**
* @description Insert several elements after the specified position.
* @param pos The position you want to insert.
* @param element The element you want to insert.
* @param num The number of elements you want to insert (default 1).
* @param pos - The position you want to insert.
* @param element - The element you want to insert.
* @param num - The number of elements you want to insert (default 1).
* @returns The size of container after inserting.
* @example

@@ -233,3 +262,3 @@ * const container = new Vector([1, 2, 3]);

*/
abstract insert(pos: number, element: T, num?: number): void;
abstract insert(pos: number, element: T, num?: number): number;
/**

@@ -244,2 +273,3 @@ * @description Reverses the container.

* @description Removes the duplication of elements in the container.
* @returns The size of container after inserting.
* @example

@@ -249,6 +279,6 @@ * const container = new Vector([1, 1, 3, 2, 2, 5, 5, 2]);

*/
abstract unique(): void;
abstract unique(): number;
/**
* @description Sort the container.
* @param cmp Comparison function.
* @param cmp - Comparison function to sort.
* @example

@@ -262,8 +292,11 @@ * const container = new Vector([3, 1, 10]);

declare class LinkListIterator<T> extends ContainerIterator<T> {
pre: () => this;
next: () => this;
get pointer(): T;
set pointer(newValue: T);
equals(obj: LinkListIterator<T>): boolean;
copy(): LinkListIterator<T>;
// @ts-ignore
equals(iter: LinkListIterator<T>): boolean;
// @ts-ignore
pre(): this;
// @ts-ignore
next(): this;
}

@@ -279,27 +312,29 @@ declare class LinkList<T> extends SequentialContainer<T> {

back(): T | undefined;
forEach(callback: (element: T, index: number, list: LinkList<T>) => void): void;
getElementByPos(pos: number): T;
eraseElementByPos(pos: number): void;
eraseElementByValue(_value: T): void;
eraseElementByPos(pos: number): number;
eraseElementByValue(_value: T): number;
eraseElementByIterator(iter: LinkListIterator<T>): LinkListIterator<T>;
pushBack(element: T): void;
popBack(): void;
setElementByPos(pos: number, element: T): void;
insert(pos: number, element: T, num?: number): void;
find(element: T): LinkListIterator<T>;
reverse(): void;
unique(): void;
sort(cmp?: (x: T, y: T) => number): void;
pushBack(element: T): number;
popBack(): T | undefined;
/**
* @description Push an element to the front.
* @param element The element you want to push.
* @param element - The element you want to push.
* @returns The size of queue after pushing.
*/
pushFront(element: T): void;
pushFront(element: T): number;
/**
* @description Removes the first element.
* @returns The element you popped.
*/
popFront(): void;
popFront(): T | undefined;
setElementByPos(pos: number, element: T): void;
insert(pos: number, element: T, num?: number): number;
find(element: T): LinkListIterator<T>;
reverse(): void;
unique(): number;
sort(cmp?: (x: T, y: T) => number): void;
/**
* @description Merges two sorted lists.
* @param list The other list you want to merge (must be sorted).
* @param list - The other list you want to merge (must be sorted).
* @returns The size of list after merging.
* @example

@@ -310,3 +345,4 @@ * const linkA = new LinkList([1, 3, 5]);

*/
merge(list: LinkList<T>): void;
merge(list: LinkList<T>): number;
forEach(callback: (element: T, index: number, list: LinkList<T>) => void): void;
[Symbol.iterator](): Generator<T, void, unknown>;

@@ -313,0 +349,0 @@ }

@@ -11,2 +11,5 @@ "use strict";

}
equals(t) {
return this.i === t.i;
}
}

@@ -16,9 +19,12 @@

constructor() {
this.i = 0;
this.h = 0;
}
get length() {
return this.h;
}
size() {
return this.i;
return this.h;
}
empty() {
return this.i === 0;
return this.h === 0;
}

@@ -31,9 +37,4 @@ }

class LinkNode {
constructor(t) {
this.h = undefined;
this.o = undefined;
this.u = undefined;
this.h = t;
}
function throwIteratorAccessError() {
throw new RangeError("Iterator access denied!");
}

@@ -44,17 +45,17 @@

super(s);
this.l = t;
this.L = i;
this.i = t;
this.o = i;
if (this.iteratorType === 0) {
this.pre = function() {
if (this.l.o === this.L) {
throw new RangeError("LinkList iterator access denied!");
if (this.i.u === this.o) {
throwIteratorAccessError();
}
this.l = this.l.o;
this.i = this.i.u;
return this;
};
this.next = function() {
if (this.l === this.L) {
throw new RangeError("LinkList iterator access denied!");
if (this.i === this.o) {
throwIteratorAccessError();
}
this.l = this.l.u;
this.i = this.i.l;
return this;

@@ -64,13 +65,13 @@ };

this.pre = function() {
if (this.l.u === this.L) {
throw new RangeError("LinkList iterator access denied!");
if (this.i.l === this.o) {
throwIteratorAccessError();
}
this.l = this.l.u;
this.i = this.i.l;
return this;
};
this.next = function() {
if (this.l === this.L) {
throw new RangeError("LinkList iterator access denied!");
if (this.i === this.o) {
throwIteratorAccessError();
}
this.l = this.l.o;
this.i = this.i.u;
return this;

@@ -81,18 +82,15 @@ };

get pointer() {
if (this.l === this.L) {
throw new RangeError("LinkList iterator access denied!");
if (this.i === this.o) {
throwIteratorAccessError();
}
return this.l.h;
return this.i.I;
}
set pointer(t) {
if (this.l === this.L) {
throw new RangeError("LinkList iterator access denied!");
if (this.i === this.o) {
throwIteratorAccessError();
}
this.l.h = t;
this.i.I = t;
}
equals(t) {
return this.l === t.l;
}
copy() {
return new LinkListIterator(this.l, this.L, this.iteratorType);
return new LinkListIterator(this.i, this.o, this.iteratorType);
}

@@ -104,5 +102,4 @@ }

super();
this.L = new LinkNode;
this.k = undefined;
this.g = undefined;
this.o = {};
this.L = this.p = this.o.u = this.o.l = this.o;
const i = this;

@@ -113,162 +110,159 @@ t.forEach((function(t) {

}
g(t) {
const {u: i, l: s} = t;
i.l = s;
s.u = i;
if (t === this.L) {
this.L = s;
}
if (t === this.p) {
this.p = i;
}
this.h -= 1;
}
k(t, i) {
const s = i.l;
const r = {
I: t,
u: i,
l: s
};
i.l = r;
s.u = r;
if (i === this.o) {
this.L = r;
}
if (s === this.o) {
this.p = r;
}
this.h += 1;
}
clear() {
this.i = 0;
this.k = this.g = undefined;
this.L.o = this.L.u = undefined;
this.h = 0;
this.L = this.p = this.o.u = this.o.l = this.o;
}
begin() {
return new LinkListIterator(this.k || this.L, this.L);
return new LinkListIterator(this.L, this.o);
}
end() {
return new LinkListIterator(this.L, this.L);
return new LinkListIterator(this.o, this.o);
}
rBegin() {
return new LinkListIterator(this.g || this.L, this.L, 1);
return new LinkListIterator(this.p, this.o, 1);
}
rEnd() {
return new LinkListIterator(this.L, this.L, 1);
return new LinkListIterator(this.o, this.o, 1);
}
front() {
return this.k ? this.k.h : undefined;
return this.L.I;
}
back() {
return this.g ? this.g.h : undefined;
return this.p.I;
}
forEach(t) {
if (!this.i) return;
let i = this.k;
let s = 0;
while (i !== this.L) {
t(i.h, s++, this);
i = i.u;
}
}
getElementByPos(t) {
if (t < 0 || t > this.i - 1) {
if (t < 0 || t > this.h - 1) {
throw new RangeError;
}
let i = this.k;
let i = this.L;
while (t--) {
i = i.u;
i = i.l;
}
return i.h;
return i.I;
}
eraseElementByPos(t) {
if (t < 0 || t > this.i - 1) {
if (t < 0 || t > this.h - 1) {
throw new RangeError;
}
if (t === 0) this.popFront(); else if (t === this.i - 1) this.popBack(); else {
let i = this.k;
while (t--) {
i = i.u;
}
i = i;
const s = i.o;
const e = i.u;
e.o = s;
s.u = e;
this.i -= 1;
let i = this.L;
while (t--) {
i = i.l;
}
this.g(i);
return this.h;
}
eraseElementByValue(t) {
while (this.k && this.k.h === t) this.popFront();
while (this.g && this.g.h === t) this.popBack();
if (!this.k) return;
let i = this.k;
while (i !== this.L) {
if (i.h === t) {
const t = i.o;
const s = i.u;
s.o = t;
t.u = s;
this.i -= 1;
let i = this.L;
while (i !== this.o) {
if (i.I === t) {
this.g(i);
}
i = i.u;
i = i.l;
}
return this.h;
}
eraseElementByIterator(t) {
const i = t.l;
if (i === this.L) {
throw new RangeError("Invalid iterator");
const i = t.i;
if (i === this.o) {
throwIteratorAccessError();
}
t = t.next();
if (this.k === i) this.popFront(); else if (this.g === i) this.popBack(); else {
const t = i.o;
const s = i.u;
s.o = t;
t.u = s;
this.i -= 1;
}
this.g(i);
return t;
}
pushBack(t) {
this.i += 1;
const i = new LinkNode(t);
if (!this.g) {
this.k = this.g = i;
this.L.u = this.k;
this.k.o = this.L;
} else {
this.g.u = i;
i.o = this.g;
this.g = i;
}
this.g.u = this.L;
this.L.o = this.g;
this.k(t, this.p);
return this.h;
}
popBack() {
if (!this.g) return;
this.i -= 1;
if (this.k === this.g) {
this.k = this.g = undefined;
this.L.u = undefined;
} else {
this.g = this.g.o;
this.g.u = this.L;
}
this.L.o = this.g;
if (this.h === 0) return;
const t = this.p.I;
this.g(this.p);
return t;
}
pushFront(t) {
this.k(t, this.o);
return this.h;
}
popFront() {
if (this.h === 0) return;
const t = this.L.I;
this.g(this.L);
return t;
}
setElementByPos(t, i) {
if (t < 0 || t > this.i - 1) {
if (t < 0 || t > this.h - 1) {
throw new RangeError;
}
let s = this.k;
let s = this.L;
while (t--) {
s = s.u;
s = s.l;
}
s.h = i;
s.I = i;
}
insert(t, i, s = 1) {
if (t < 0 || t > this.i) {
if (t < 0 || t > this.h) {
throw new RangeError;
}
if (s <= 0) return;
if (s <= 0) return this.h;
if (t === 0) {
while (s--) this.pushFront(i);
} else if (t === this.i) {
} else if (t === this.h) {
while (s--) this.pushBack(i);
} else {
let e = this.k;
let r = this.L;
for (let i = 1; i < t; ++i) {
e = e.u;
r = r.l;
}
const h = e.u;
this.i += s;
const e = r.l;
this.h += s;
while (s--) {
e.u = new LinkNode(i);
e.u.o = e;
e = e.u;
r.l = {
I: i,
u: r
};
r.l.u = r;
r = r.l;
}
e.u = h;
h.o = e;
r.l = e;
e.u = r;
}
return this.h;
}
find(t) {
if (!this.k) return this.end();
let i = this.k;
while (i !== this.L) {
if (i.h === t) {
return new LinkListIterator(i, this.L);
let i = this.L;
while (i !== this.o) {
if (i.I === t) {
return new LinkListIterator(i, this.o);
}
i = i.u;
i = i.l;
}

@@ -278,12 +272,12 @@ return this.end();

reverse() {
if (this.i <= 1) return;
let t = this.k;
let i = this.g;
if (this.h <= 1) return;
let t = this.L;
let i = this.p;
let s = 0;
while (s << 1 < this.i) {
const e = t.h;
t.h = i.h;
i.h = e;
t = t.u;
i = i.o;
while (s << 1 < this.h) {
const r = t.I;
t.I = i.I;
i.I = r;
t = t.l;
i = i.u;
s += 1;

@@ -293,17 +287,20 @@ }

unique() {
if (this.i <= 1) return;
let t = this.k;
while (t !== this.L) {
if (this.h <= 1) {
return this.h;
}
let t = this.L;
while (t !== this.o) {
let i = t;
while (i.u && i.h === i.u.h) {
i = i.u;
this.i -= 1;
while (i.l !== this.o && i.I === i.l.I) {
i = i.l;
this.h -= 1;
}
t.u = i.u;
t.u.o = t;
t = t.u;
t.l = i.l;
t.l.u = t;
t = t.l;
}
return this.h;
}
sort(t) {
if (this.i <= 1) return;
if (this.h <= 1) return;
const i = [];

@@ -314,71 +311,40 @@ this.forEach((function(t) {

i.sort(t);
let s = this.k;
let s = this.L;
i.forEach((function(t) {
s.h = t;
s = s.u;
s.I = t;
s = s.l;
}));
}
pushFront(t) {
this.i += 1;
const i = new LinkNode(t);
if (!this.k) {
this.k = this.g = i;
this.g.u = this.L;
this.L.o = this.g;
} else {
i.u = this.k;
this.k.o = i;
this.k = i;
}
this.L.u = this.k;
this.k.o = this.L;
}
popFront() {
if (!this.k) return;
this.i -= 1;
if (this.k === this.g) {
this.k = this.g = undefined;
this.L.o = this.g;
} else {
this.k = this.k.u;
this.k.o = this.L;
}
this.L.u = this.k;
}
merge(t) {
const i = this;
if (!this.k) {
if (this.h === 0) {
t.forEach((function(t) {
i.pushBack(t);
}));
return;
} else {
let s = this.L;
t.forEach((function(t) {
while (s !== i.o && s.I <= t) {
s = s.l;
}
i.k(t, s.u);
}));
}
let s = this.k;
t.forEach((function(t) {
while (s && s !== i.L && s.h <= t) {
s = s.u;
}
if (s === i.L) {
i.pushBack(t);
s = i.g;
} else if (s === i.k) {
i.pushFront(t);
s = i.k;
} else {
i.i += 1;
const e = s.o;
e.u = new LinkNode(t);
e.u.o = e;
e.u.u = s;
s.o = e.u;
}
}));
return this.h;
}
forEach(t) {
let i = this.L;
let s = 0;
while (i !== this.o) {
t(i.I, s++, this);
i = i.l;
}
}
[Symbol.iterator]() {
return function*() {
if (!this.k) return;
let t = this.k;
while (t !== this.L) {
yield t.h;
t = t.u;
if (this.h === 0) return;
let t = this.L;
while (t !== this.o) {
yield t.I;
t = t.l;
}

@@ -385,0 +351,0 @@ }.bind(this)();

@@ -0,1 +1,4 @@

/**
* @description The iterator type including `NORMAL` and `REVERSE`.
*/
declare const enum IteratorType {

@@ -8,10 +11,18 @@ NORMAL = 0,

* @description Iterator's type.
* @example console.log(container.end().iteratorType === IteratorType.NORMAL); // true
* @example
* console.log(container.end().iteratorType === IteratorType.NORMAL); // true
*/
readonly iteratorType: IteratorType;
protected constructor(iteratorType?: IteratorType);
/**
* @param iter - The other iterator you want to compare.
* @returns Whether this equals to obj.
* @example
* container.find(1).equals(container.end());
*/
equals(iter: ContainerIterator<T>): boolean;
/**
* @description Pointers to element.
* @return The value of the pointer's element.
* @example const val = container.begin().pointer;
* @returns The value of the pointer's element.
* @example
* const val = container.begin().pointer;
*/

@@ -21,4 +32,5 @@ abstract get pointer(): T;

* @description Set pointer's value (some containers are unavailable).
* @param newValue The new value you want to set.
* @example (<LinkList<number>>container).begin().pointer = 1;
* @param newValue - The new value you want to set.
* @example
* (<LinkList<number>>container).begin().pointer = 1;
*/

@@ -28,2 +40,3 @@ abstract set pointer(newValue: T);

* @description Move `this` iterator to pre.
* @returns The iterator's self.
* @example

@@ -39,2 +52,3 @@ * const iter = container.find(1); // container = [0, 1]

* @description Move `this` iterator to next.
* @returns The iterator's self.
* @example

@@ -49,10 +63,4 @@ * const iter = container.find(1); // container = [1, 2]

/**
* @param obj The other iterator you want to compare.
* @return Boolean about if this equals to obj.
* @example container.find(1).equals(container.end());
*/
abstract equals(obj: ContainerIterator<T>): boolean;
/**
* @description Get a copy of itself.
* @return The copy of self.
* @returns The copy of self.
* @example

@@ -69,5 +77,12 @@ * const iter = container.find(1); // container = [1, 2]

/**
* @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

@@ -77,3 +92,3 @@ */

/**
* @return Boolean about if the container is empty.
* @returns Whether the container is empty.
* @example

@@ -94,3 +109,3 @@ * container.clear();

/**
* @return Iterator pointing to the beginning element.
* @returns Iterator pointing to the beginning element.
* @example

@@ -105,3 +120,3 @@ * const begin = container.begin();

/**
* @return Iterator pointing to the super end like c++.
* @returns Iterator pointing to the super end like c++.
* @example

@@ -116,3 +131,3 @@ * const begin = container.begin();

/**
* @return Iterator pointing to the end element.
* @returns Iterator pointing to the end element.
* @example

@@ -127,3 +142,3 @@ * const rBegin = container.rBegin();

/**
* @return Iterator pointing to the super begin like c++.
* @returns Iterator pointing to the super begin like c++.
* @example

@@ -138,22 +153,24 @@ * const rBegin = container.rBegin();

/**
* @return The first element of the container.
* @returns The first element of the container.
*/
abstract front(): T | undefined;
/**
* @return The last element of the container.
* @returns The last element of the container.
*/
abstract back(): T | undefined;
/**
* @param element - The element you want to find.
* @returns An iterator pointing to the element if found, or super end if not found.
* @example
* container.find(1).equals(container.end());
*/
abstract find(element: T): ContainerIterator<T>;
/**
* @description Iterate over all elements in the container.
* @param callback Callback function like Array.forEach.
* @example container.forEach((element, index) => console.log(element, index));
* @param callback - Callback function like Array.forEach.
* @example
* container.forEach((element, index) => console.log(element, index));
*/
abstract forEach(callback: (element: T, index: number, container: Container<T>) => void): void;
/**
* @param element The element you want to find.
* @return An iterator pointing to the element if found, or super end if not found.
* @example container.find(1).equals(container.end());
*/
abstract find(element: T): ContainerIterator<T>;
/**
* @description Gets the value of the element at the specified position.

@@ -166,9 +183,12 @@ * @example

* @description Removes the element at the specified position.
* @param pos The element's position you want to remove.
* @param pos - The element's position you want to remove.
* @returns The container length after erasing.
* @example
* container.eraseElementByPos(-1); // throw a RangeError
*/
abstract eraseElementByPos(pos: number): void;
abstract eraseElementByPos(pos: number): number;
/**
* @description Removes element by iterator and move `iter` to next.
* @param iter The iterator you want to erase.
* @param iter - The iterator you want to erase.
* @returns The next iterator.
* @example

@@ -186,4 +206,7 @@ * container.eraseElementByIterator(container.begin());

*/
abstract [Symbol.iterator](): Generator<T, void, undefined>;
abstract [Symbol.iterator](): Generator<T, void>;
}
/**
* @description The initial data type passed in when initializing the container.
*/
type initContainer<T> = ({

@@ -201,14 +224,17 @@ size: number;

* @description Push the element to the back.
* @param element The element you want to push.
* @param element - The element you want to push.
* @returns The size of container after pushing.
*/
abstract pushBack(element: T): void;
abstract pushBack(element: T): number;
/**
* @description Removes the last element.
* @returns The element you popped.
*/
abstract popBack(): void;
abstract popBack(): T | undefined;
/**
* @description Sets element by position.
* @param pos The position you want to change.
* @param element The element's value you want to update.
* @example container.setElementByPos(-1, 1); // throw a RangeError
* @param pos - The position you want to change.
* @param element - The element's value you want to update.
* @example
* container.setElementByPos(-1, 1); // throw a RangeError
*/

@@ -218,11 +244,14 @@ abstract setElementByPos(pos: number, element: T): void;

* @description Removes the elements of the specified value.
* @param value The value you want to remove.
* @example container.eraseElementByValue(-1);
* @param value - The value you want to remove.
* @returns The size of container after erasing.
* @example
* container.eraseElementByValue(-1);
*/
abstract eraseElementByValue(value: T): void;
abstract eraseElementByValue(value: T): number;
/**
* @description Insert several elements after the specified position.
* @param pos The position you want to insert.
* @param element The element you want to insert.
* @param num The number of elements you want to insert (default 1).
* @param pos - The position you want to insert.
* @param element - The element you want to insert.
* @param num - The number of elements you want to insert (default 1).
* @returns The size of container after inserting.
* @example

@@ -233,3 +262,3 @@ * const container = new Vector([1, 2, 3]);

*/
abstract insert(pos: number, element: T, num?: number): void;
abstract insert(pos: number, element: T, num?: number): number;
/**

@@ -244,2 +273,3 @@ * @description Reverses the container.

* @description Removes the duplication of elements in the container.
* @returns The size of container after inserting.
* @example

@@ -249,6 +279,6 @@ * const container = new Vector([1, 1, 3, 2, 2, 5, 5, 2]);

*/
abstract unique(): void;
abstract unique(): number;
/**
* @description Sort the container.
* @param cmp Comparison function.
* @param cmp - Comparison function to sort.
* @example

@@ -262,8 +292,11 @@ * const container = new Vector([3, 1, 10]);

declare class LinkListIterator<T> extends ContainerIterator<T> {
pre: () => this;
next: () => this;
get pointer(): T;
set pointer(newValue: T);
equals(obj: LinkListIterator<T>): boolean;
copy(): LinkListIterator<T>;
// @ts-ignore
equals(iter: LinkListIterator<T>): boolean;
// @ts-ignore
pre(): this;
// @ts-ignore
next(): this;
}

@@ -279,27 +312,29 @@ declare class LinkList<T> extends SequentialContainer<T> {

back(): T | undefined;
forEach(callback: (element: T, index: number, list: LinkList<T>) => void): void;
getElementByPos(pos: number): T;
eraseElementByPos(pos: number): void;
eraseElementByValue(_value: T): void;
eraseElementByPos(pos: number): number;
eraseElementByValue(_value: T): number;
eraseElementByIterator(iter: LinkListIterator<T>): LinkListIterator<T>;
pushBack(element: T): void;
popBack(): void;
setElementByPos(pos: number, element: T): void;
insert(pos: number, element: T, num?: number): void;
find(element: T): LinkListIterator<T>;
reverse(): void;
unique(): void;
sort(cmp?: (x: T, y: T) => number): void;
pushBack(element: T): number;
popBack(): T | undefined;
/**
* @description Push an element to the front.
* @param element The element you want to push.
* @param element - The element you want to push.
* @returns The size of queue after pushing.
*/
pushFront(element: T): void;
pushFront(element: T): number;
/**
* @description Removes the first element.
* @returns The element you popped.
*/
popFront(): void;
popFront(): T | undefined;
setElementByPos(pos: number, element: T): void;
insert(pos: number, element: T, num?: number): number;
find(element: T): LinkListIterator<T>;
reverse(): void;
unique(): number;
sort(cmp?: (x: T, y: T) => number): void;
/**
* @description Merges two sorted lists.
* @param list The other list you want to merge (must be sorted).
* @param list - The other list you want to merge (must be sorted).
* @returns The size of list after merging.
* @example

@@ -310,3 +345,4 @@ * const linkA = new LinkList([1, 3, 5]);

*/
merge(list: LinkList<T>): void;
merge(list: LinkList<T>): number;
forEach(callback: (element: T, index: number, list: LinkList<T>) => void): void;
[Symbol.iterator](): Generator<T, void, unknown>;

@@ -313,0 +349,0 @@ }

@@ -30,10 +30,10 @@ var extendStatics = function(t, i) {

ops: []
}, e, r, s, h;
return h = {
}, r, e, s, o;
return o = {
next: verb(0),
throw: verb(1),
return: verb(2)
}, typeof Symbol === "function" && (h[Symbol.iterator] = function() {
}, typeof Symbol === "function" && (o[Symbol.iterator] = function() {
return this;
}), h;
}), o;
function verb(t) {

@@ -44,12 +44,12 @@ return function(i) {

}
function step(o) {
if (e) throw new TypeError("Generator is already executing.");
while (h && (h = 0, o[0] && (n = 0)), n) try {
if (e = 1, r && (s = o[0] & 2 ? r["return"] : o[0] ? r["throw"] || ((s = r["return"]) && s.call(r),
0) : r.next) && !(s = s.call(r, o[1])).done) return s;
if (r = 0, s) o = [ o[0] & 2, s.value ];
switch (o[0]) {
function step(h) {
if (r) throw new TypeError("Generator is already executing.");
while (o && (o = 0, h[0] && (n = 0)), n) try {
if (r = 1, e && (s = h[0] & 2 ? e["return"] : h[0] ? e["throw"] || ((s = e["return"]) && s.call(e),
0) : e.next) && !(s = s.call(e, h[1])).done) return s;
if (e = 0, s) h = [ h[0] & 2, s.value ];
switch (h[0]) {
case 0:
case 1:
s = o;
s = h;
break;

@@ -60,3 +60,3 @@

return {
value: o[1],
value: h[1],
done: false

@@ -67,8 +67,8 @@ };

n.label++;
r = o[1];
o = [ 0 ];
e = h[1];
h = [ 0 ];
continue;
case 7:
o = n.ops.pop();
h = n.ops.pop();
n.trys.pop();

@@ -78,13 +78,13 @@ continue;

default:
if (!(s = n.trys, s = s.length > 0 && s[s.length - 1]) && (o[0] === 6 || o[0] === 2)) {
if (!(s = n.trys, s = s.length > 0 && s[s.length - 1]) && (h[0] === 6 || h[0] === 2)) {
n = 0;
continue;
}
if (o[0] === 3 && (!s || o[1] > s[0] && o[1] < s[3])) {
n.label = o[1];
if (h[0] === 3 && (!s || h[1] > s[0] && h[1] < s[3])) {
n.label = h[1];
break;
}
if (o[0] === 6 && n.label < s[1]) {
if (h[0] === 6 && n.label < s[1]) {
n.label = s[1];
s = o;
s = h;
break;

@@ -94,3 +94,3 @@ }

n.label = s[2];
n.ops.push(o);
n.ops.push(h);
break;

@@ -102,12 +102,12 @@ }

}
o = i.call(t, n);
h = i.call(t, n);
} catch (t) {
o = [ 6, t ];
r = 0;
h = [ 6, t ];
e = 0;
} finally {
e = s = 0;
r = s = 0;
}
if (o[0] & 5) throw o[1];
if (h[0] & 5) throw h[1];
return {
value: o[0] ? o[1] : void 0,
value: h[0] ? h[1] : void 0,
done: true

@@ -125,2 +125,5 @@ };

}
ContainerIterator.prototype.equals = function(t) {
return this.t === t.t;
};
return ContainerIterator;

@@ -131,9 +134,16 @@ }();

function Base() {
this.t = 0;
this.i = 0;
}
Object.defineProperty(Base.prototype, "length", {
get: function() {
return this.i;
},
enumerable: false,
configurable: true
});
Base.prototype.size = function() {
return this.t;
return this.i;
};
Base.prototype.empty = function() {
return this.t === 0;
return this.i === 0;
};

@@ -159,63 +169,57 @@ return Base;

var LinkNode = function() {
function LinkNode(t) {
this.i = undefined;
this.h = undefined;
this.o = undefined;
this.i = t;
}
return LinkNode;
}();
function throwIteratorAccessError() {
throw new RangeError("Iterator access denied!");
}
var LinkListIterator = function(t) {
__extends(LinkListIterator, t);
function LinkListIterator(i, n, e) {
var r = t.call(this, e) || this;
r.u = i;
r.L = n;
if (r.iteratorType === 0) {
r.pre = function() {
if (this.u.h === this.L) {
throw new RangeError("LinkList iterator access denied!");
function LinkListIterator(i, n, r) {
var e = t.call(this, r) || this;
e.t = i;
e.o = n;
if (e.iteratorType === 0) {
e.pre = function() {
if (this.t.h === this.o) {
throwIteratorAccessError();
}
this.u = this.u.h;
this.t = this.t.h;
return this;
};
r.next = function() {
if (this.u === this.L) {
throw new RangeError("LinkList iterator access denied!");
e.next = function() {
if (this.t === this.o) {
throwIteratorAccessError();
}
this.u = this.u.o;
this.t = this.t.u;
return this;
};
} else {
r.pre = function() {
if (this.u.o === this.L) {
throw new RangeError("LinkList iterator access denied!");
e.pre = function() {
if (this.t.u === this.o) {
throwIteratorAccessError();
}
this.u = this.u.o;
this.t = this.t.u;
return this;
};
r.next = function() {
if (this.u === this.L) {
throw new RangeError("LinkList iterator access denied!");
e.next = function() {
if (this.t === this.o) {
throwIteratorAccessError();
}
this.u = this.u.h;
this.t = this.t.h;
return this;
};
}
return r;
return e;
}
Object.defineProperty(LinkListIterator.prototype, "pointer", {
get: function() {
if (this.u === this.L) {
throw new RangeError("LinkList iterator access denied!");
if (this.t === this.o) {
throwIteratorAccessError();
}
return this.u.i;
return this.t.L;
},
set: function(t) {
if (this.u === this.L) {
throw new RangeError("LinkList iterator access denied!");
if (this.t === this.o) {
throwIteratorAccessError();
}
this.u.i = t;
this.t.L = t;
},

@@ -225,7 +229,4 @@ enumerable: false,

});
LinkListIterator.prototype.equals = function(t) {
return this.u === t.u;
};
LinkListIterator.prototype.copy = function() {
return new LinkListIterator(this.u, this.L, this.iteratorType);
return new LinkListIterator(this.t, this.o, this.iteratorType);
};

@@ -242,45 +243,63 @@ return LinkListIterator;

var n = t.call(this) || this;
n.L = new LinkNode;
n.l = undefined;
n.k = undefined;
var e = n;
n.o = {};
n.l = n.v = n.o.h = n.o.u = n.o;
var r = n;
i.forEach((function(t) {
e.pushBack(t);
r.pushBack(t);
}));
return n;
}
LinkList.prototype.k = function(t) {
var i = t.h, n = t.u;
i.u = n;
n.h = i;
if (t === this.l) {
this.l = n;
}
if (t === this.v) {
this.v = i;
}
this.i -= 1;
};
LinkList.prototype._ = function(t, i) {
var n = i.u;
var r = {
L: t,
h: i,
u: n
};
i.u = r;
n.h = r;
if (i === this.o) {
this.l = r;
}
if (n === this.o) {
this.v = r;
}
this.i += 1;
};
LinkList.prototype.clear = function() {
this.t = 0;
this.l = this.k = undefined;
this.L.h = this.L.o = undefined;
this.i = 0;
this.l = this.v = this.o.h = this.o.u = this.o;
};
LinkList.prototype.begin = function() {
return new LinkListIterator(this.l || this.L, this.L);
return new LinkListIterator(this.l, this.o);
};
LinkList.prototype.end = function() {
return new LinkListIterator(this.L, this.L);
return new LinkListIterator(this.o, this.o);
};
LinkList.prototype.rBegin = function() {
return new LinkListIterator(this.k || this.L, this.L, 1);
return new LinkListIterator(this.v, this.o, 1);
};
LinkList.prototype.rEnd = function() {
return new LinkListIterator(this.L, this.L, 1);
return new LinkListIterator(this.o, this.o, 1);
};
LinkList.prototype.front = function() {
return this.l ? this.l.i : undefined;
return this.l.L;
};
LinkList.prototype.back = function() {
return this.k ? this.k.i : undefined;
return this.v.L;
};
LinkList.prototype.forEach = function(t) {
if (!this.t) return;
var i = this.l;
var n = 0;
while (i !== this.L) {
t(i.i, n++, this);
i = i.o;
}
};
LinkList.prototype.getElementByPos = function(t) {
if (t < 0 || t > this.t - 1) {
if (t < 0 || t > this.i - 1) {
throw new RangeError;

@@ -290,83 +309,58 @@ }

while (t--) {
i = i.o;
i = i.u;
}
return i.i;
return i.L;
};
LinkList.prototype.eraseElementByPos = function(t) {
if (t < 0 || t > this.t - 1) {
if (t < 0 || t > this.i - 1) {
throw new RangeError;
}
if (t === 0) this.popFront(); else if (t === this.t - 1) this.popBack(); else {
var i = this.l;
while (t--) {
i = i.o;
}
i = i;
var n = i.h;
var e = i.o;
e.h = n;
n.o = e;
this.t -= 1;
var i = this.l;
while (t--) {
i = i.u;
}
this.k(i);
return this.i;
};
LinkList.prototype.eraseElementByValue = function(t) {
while (this.l && this.l.i === t) this.popFront();
while (this.k && this.k.i === t) this.popBack();
if (!this.l) return;
var i = this.l;
while (i !== this.L) {
if (i.i === t) {
var n = i.h;
var e = i.o;
e.h = n;
n.o = e;
this.t -= 1;
while (i !== this.o) {
if (i.L === t) {
this.k(i);
}
i = i.o;
i = i.u;
}
return this.i;
};
LinkList.prototype.eraseElementByIterator = function(t) {
var i = t.u;
if (i === this.L) {
throw new RangeError("Invalid iterator");
var i = t.t;
if (i === this.o) {
throwIteratorAccessError();
}
t = t.next();
if (this.l === i) this.popFront(); else if (this.k === i) this.popBack(); else {
var n = i.h;
var e = i.o;
e.h = n;
n.o = e;
this.t -= 1;
}
this.k(i);
return t;
};
LinkList.prototype.pushBack = function(t) {
this.t += 1;
var i = new LinkNode(t);
if (!this.k) {
this.l = this.k = i;
this.L.o = this.l;
this.l.h = this.L;
} else {
this.k.o = i;
i.h = this.k;
this.k = i;
}
this.k.o = this.L;
this.L.h = this.k;
this._(t, this.v);
return this.i;
};
LinkList.prototype.popBack = function() {
if (!this.k) return;
this.t -= 1;
if (this.l === this.k) {
this.l = this.k = undefined;
this.L.o = undefined;
} else {
this.k = this.k.h;
this.k.o = this.L;
}
this.L.h = this.k;
if (this.i === 0) return;
var t = this.v.L;
this.k(this.v);
return t;
};
LinkList.prototype.pushFront = function(t) {
this._(t, this.o);
return this.i;
};
LinkList.prototype.popFront = function() {
if (this.i === 0) return;
var t = this.l.L;
this.k(this.l);
return t;
};
LinkList.prototype.setElementByPos = function(t, i) {
if (t < 0 || t > this.t - 1) {
if (t < 0 || t > this.i - 1) {
throw new RangeError;

@@ -376,5 +370,5 @@ }

while (t--) {
n = n.o;
n = n.u;
}
n.i = i;
n.L = i;
};

@@ -385,34 +379,37 @@ LinkList.prototype.insert = function(t, i, n) {

}
if (t < 0 || t > this.t) {
if (t < 0 || t > this.i) {
throw new RangeError;
}
if (n <= 0) return;
if (n <= 0) return this.i;
if (t === 0) {
while (n--) this.pushFront(i);
} else if (t === this.t) {
} else if (t === this.i) {
while (n--) this.pushBack(i);
} else {
var e = this.l;
for (var r = 1; r < t; ++r) {
e = e.o;
var r = this.l;
for (var e = 1; e < t; ++e) {
r = r.u;
}
var s = e.o;
this.t += n;
var s = r.u;
this.i += n;
while (n--) {
e.o = new LinkNode(i);
e.o.h = e;
e = e.o;
r.u = {
L: i,
h: r
};
r.u.h = r;
r = r.u;
}
e.o = s;
s.h = e;
r.u = s;
s.h = r;
}
return this.i;
};
LinkList.prototype.find = function(t) {
if (!this.l) return this.end();
var i = this.l;
while (i !== this.L) {
if (i.i === t) {
return new LinkListIterator(i, this.L);
while (i !== this.o) {
if (i.L === t) {
return new LinkListIterator(i, this.o);
}
i = i.o;
i = i.u;
}

@@ -422,11 +419,11 @@ return this.end();

LinkList.prototype.reverse = function() {
if (this.t <= 1) return;
if (this.i <= 1) return;
var t = this.l;
var i = this.k;
var i = this.v;
var n = 0;
while (n << 1 < this.t) {
var e = t.i;
t.i = i.i;
i.i = e;
t = t.o;
while (n << 1 < this.i) {
var r = t.L;
t.L = i.L;
i.L = r;
t = t.u;
i = i.h;

@@ -437,17 +434,20 @@ n += 1;

LinkList.prototype.unique = function() {
if (this.t <= 1) return;
if (this.i <= 1) {
return this.i;
}
var t = this.l;
while (t !== this.L) {
while (t !== this.o) {
var i = t;
while (i.o && i.i === i.o.i) {
i = i.o;
this.t -= 1;
while (i.u !== this.o && i.L === i.u.L) {
i = i.u;
this.i -= 1;
}
t.o = i.o;
t.o.h = t;
t = t.o;
t.u = i.u;
t.u.h = t;
t = t.u;
}
return this.i;
};
LinkList.prototype.sort = function(t) {
if (this.t <= 1) return;
if (this.i <= 1) return;
var i = [];

@@ -460,62 +460,31 @@ this.forEach((function(t) {

i.forEach((function(t) {
n.i = t;
n = n.o;
n.L = t;
n = n.u;
}));
};
LinkList.prototype.pushFront = function(t) {
this.t += 1;
var i = new LinkNode(t);
if (!this.l) {
this.l = this.k = i;
this.k.o = this.L;
this.L.h = this.k;
} else {
i.o = this.l;
this.l.h = i;
this.l = i;
}
this.L.o = this.l;
this.l.h = this.L;
};
LinkList.prototype.popFront = function() {
if (!this.l) return;
this.t -= 1;
if (this.l === this.k) {
this.l = this.k = undefined;
this.L.h = this.k;
} else {
this.l = this.l.o;
this.l.h = this.L;
}
this.L.o = this.l;
};
LinkList.prototype.merge = function(t) {
var i = this;
if (!this.l) {
if (this.i === 0) {
t.forEach((function(t) {
i.pushBack(t);
}));
return;
} else {
var n = this.l;
t.forEach((function(t) {
while (n !== i.o && n.L <= t) {
n = n.u;
}
i._(t, n.h);
}));
}
var n = this.l;
t.forEach((function(t) {
while (n && n !== i.L && n.i <= t) {
n = n.o;
}
if (n === i.L) {
i.pushBack(t);
n = i.k;
} else if (n === i.l) {
i.pushFront(t);
n = i.l;
} else {
i.t += 1;
var e = n.h;
e.o = new LinkNode(t);
e.o.h = e;
e.o.o = n;
n.h = e.o;
}
}));
return this.i;
};
LinkList.prototype.forEach = function(t) {
var i = this.l;
var n = 0;
while (i !== this.o) {
t(i.L, n++, this);
i = i.u;
}
};
LinkList.prototype[Symbol.iterator] = function() {

@@ -527,3 +496,3 @@ return function() {

case 0:
if (!this.l) return [ 2 ];
if (this.i === 0) return [ 2 ];
t = this.l;

@@ -533,8 +502,8 @@ i.label = 1;

case 1:
if (!(t !== this.L)) return [ 3, 3 ];
return [ 4, t.i ];
if (!(t !== this.o)) return [ 3, 3 ];
return [ 4, t.L ];
case 2:
i.sent();
t = t.o;
t = t.u;
return [ 3, 1 ];

@@ -541,0 +510,0 @@

/*!
* @js-sdsl/link-list v4.2.0-beta.1
* @js-sdsl/link-list v4.2.0
* https://github.com/js-sdsl/js-sdsl

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

var ContainerIterator = /** @class */function () {
/**
* @internal
*/
function ContainerIterator(iteratorType) {

@@ -145,2 +148,11 @@ if (iteratorType === void 0) {

}
/**
* @param iter - The other iterator you want to compare.
* @returns Whether this equals to obj.
* @example
* container.find(1).equals(container.end());
*/
ContainerIterator.prototype.equals = function (iter) {
return this._node === iter._node;
};
return ContainerIterator;

@@ -156,4 +168,17 @@ }();

}
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

@@ -167,3 +192,3 @@ * const container = new Vector([1, 2]);

/**
* @return Boolean about if the container is empty.
* @returns Whether the container is empty.
* @example

@@ -195,13 +220,9 @@ * container.clear();

/**
* @description Throw an iterator access error.
* @internal
*/
var LinkNode = /** @class */function () {
function LinkNode(element) {
this._value = undefined;
this._pre = undefined;
this._next = undefined;
this._value = element;
}
return LinkNode;
}();
function throwIteratorAccessError() {
throw new RangeError('Iterator access denied!');
}
var LinkListIterator = /** @class */function (_super) {

@@ -219,3 +240,3 @@ __extends(LinkListIterator, _super);

if (this._node._pre === this._header) {
throw new RangeError('LinkList iterator access denied!');
throwIteratorAccessError();
}

@@ -227,3 +248,3 @@ this._node = this._node._pre;

if (this._node === this._header) {
throw new RangeError('LinkList iterator access denied!');
throwIteratorAccessError();
}

@@ -236,3 +257,3 @@ this._node = this._node._next;

if (this._node._next === this._header) {
throw new RangeError('LinkList iterator access denied!');
throwIteratorAccessError();
}

@@ -244,3 +265,3 @@ this._node = this._node._next;

if (this._node === this._header) {
throw new RangeError('LinkList iterator access denied!');
throwIteratorAccessError();
}

@@ -256,3 +277,3 @@ this._node = this._node._pre;

if (this._node === this._header) {
throw new RangeError('LinkList iterator access denied!');
throwIteratorAccessError();
}

@@ -263,3 +284,3 @@ return this._node._value;

if (this._node === this._header) {
throw new RangeError('LinkList iterator access denied!');
throwIteratorAccessError();
}

@@ -271,5 +292,2 @@ this._node._value = newValue;

});
LinkListIterator.prototype.equals = function (obj) {
return this._node === obj._node;
};
LinkListIterator.prototype.copy = function () {

@@ -287,14 +305,4 @@ return new LinkListIterator(this._node, this._header, this.iteratorType);

var _this = _super.call(this) || this;
/**
* @internal
*/
_this._header = new LinkNode();
/**
* @internal
*/
_this._head = undefined;
/**
* @internal
*/
_this._tail = undefined;
_this._header = {};
_this._head = _this._tail = _this._header._pre = _this._header._next = _this._header;
var self = _this;

@@ -306,9 +314,44 @@ container.forEach(function (el) {

}
/**
* @internal
*/
LinkList.prototype._eraseNode = function (node) {
var _pre = node._pre,
_next = node._next;
_pre._next = _next;
_next._pre = _pre;
if (node === this._head) {
this._head = _next;
}
if (node === this._tail) {
this._tail = _pre;
}
this._length -= 1;
};
/**
* @internal
*/
LinkList.prototype._insertNode = function (value, pre) {
var next = pre._next;
var node = {
_value: value,
_pre: pre,
_next: next
};
pre._next = node;
next._pre = node;
if (pre === this._header) {
this._head = node;
}
if (next === this._header) {
this._tail = node;
}
this._length += 1;
};
LinkList.prototype.clear = function () {
this._length = 0;
this._head = this._tail = undefined;
this._header._pre = this._header._next = undefined;
this._head = this._tail = this._header._pre = this._header._next = this._header;
};
LinkList.prototype.begin = function () {
return new LinkListIterator(this._head || this._header, this._header);
return new LinkListIterator(this._head, this._header);
};

@@ -319,3 +362,3 @@ LinkList.prototype.end = function () {

LinkList.prototype.rBegin = function () {
return new LinkListIterator(this._tail || this._header, this._header, 1 /* IteratorType.REVERSE */);
return new LinkListIterator(this._tail, this._header, 1 /* IteratorType.REVERSE */);
};

@@ -328,16 +371,7 @@

LinkList.prototype.front = function () {
return this._head ? this._head._value : undefined;
return this._head._value;
};
LinkList.prototype.back = function () {
return this._tail ? this._tail._value : undefined;
return this._tail._value;
};
LinkList.prototype.forEach = function (callback) {
if (!this._length) return;
var curNode = this._head;
var index = 0;
while (curNode !== this._header) {
callback(curNode._value, index++, this);
curNode = curNode._next;
}
};
LinkList.prototype.getElementByPos = function (pos) {

@@ -357,73 +391,57 @@ if (pos < 0 || pos > this._length - 1) {

}
if (pos === 0) this.popFront();else if (pos === this._length - 1) this.popBack();else {
var curNode = this._head;
while (pos--) {
curNode = curNode._next;
}
curNode = curNode;
var _pre = curNode._pre;
var _next = curNode._next;
_next._pre = _pre;
_pre._next = _next;
this._length -= 1;
var curNode = this._head;
while (pos--) {
curNode = curNode._next;
}
this._eraseNode(curNode);
return this._length;
};
LinkList.prototype.eraseElementByValue = function (_value) {
while (this._head && this._head._value === _value) this.popFront();
while (this._tail && this._tail._value === _value) this.popBack();
if (!this._head) return;
var curNode = this._head;
while (curNode !== this._header) {
if (curNode._value === _value) {
var _pre = curNode._pre;
var _next = curNode._next;
_next._pre = _pre;
_pre._next = _next;
this._length -= 1;
this._eraseNode(curNode);
}
curNode = curNode._next;
}
return this._length;
};
LinkList.prototype.eraseElementByIterator = function (iter) {
var _node = iter._node;
if (_node === this._header) {
throw new RangeError('Invalid iterator');
var node = iter._node;
if (node === this._header) {
throwIteratorAccessError();
}
iter = iter.next();
if (this._head === _node) this.popFront();else if (this._tail === _node) this.popBack();else {
var _pre = _node._pre;
var _next = _node._next;
_next._pre = _pre;
_pre._next = _next;
this._length -= 1;
}
this._eraseNode(node);
return iter;
};
LinkList.prototype.pushBack = function (element) {
this._length += 1;
var newTail = new LinkNode(element);
if (!this._tail) {
this._head = this._tail = newTail;
this._header._next = this._head;
this._head._pre = this._header;
} else {
this._tail._next = newTail;
newTail._pre = this._tail;
this._tail = newTail;
}
this._tail._next = this._header;
this._header._pre = this._tail;
this._insertNode(element, this._tail);
return this._length;
};
LinkList.prototype.popBack = function () {
if (!this._tail) return;
this._length -= 1;
if (this._head === this._tail) {
this._head = this._tail = undefined;
this._header._next = undefined;
} else {
this._tail = this._tail._pre;
this._tail._next = this._header;
}
this._header._pre = this._tail;
if (this._length === 0) return;
var value = this._tail._value;
this._eraseNode(this._tail);
return value;
};
/**
* @description Push an element to the front.
* @param element - The element you want to push.
* @returns The size of queue after pushing.
*/
LinkList.prototype.pushFront = function (element) {
this._insertNode(element, this._header);
return this._length;
};
/**
* @description Removes the first element.
* @returns The element you popped.
*/
LinkList.prototype.popFront = function () {
if (this._length === 0) return;
var value = this._head._value;
this._eraseNode(this._head);
return value;
};
LinkList.prototype.setElementByPos = function (pos, element) {

@@ -446,3 +464,3 @@ if (pos < 0 || pos > this._length - 1) {

}
if (num <= 0) return;
if (num <= 0) return this._length;
if (pos === 0) {

@@ -457,15 +475,18 @@ while (num--) this.pushFront(element);

}
var _next = curNode._next;
var next = curNode._next;
this._length += num;
while (num--) {
curNode._next = new LinkNode(element);
curNode._next = {
_value: element,
_pre: curNode
};
curNode._next._pre = curNode;
curNode = curNode._next;
}
curNode._next = _next;
_next._pre = curNode;
curNode._next = next;
next._pre = curNode;
}
return this._length;
};
LinkList.prototype.find = function (element) {
if (!this._head) return this.end();
var curNode = this._head;

@@ -495,7 +516,9 @@ while (curNode !== this._header) {

LinkList.prototype.unique = function () {
if (this._length <= 1) return;
if (this._length <= 1) {
return this._length;
}
var curNode = this._head;
while (curNode !== this._header) {
var tmpNode = curNode;
while (tmpNode._next && tmpNode._value === tmpNode._next._value) {
while (tmpNode._next !== this._header && tmpNode._value === tmpNode._next._value) {
tmpNode = tmpNode._next;

@@ -508,2 +531,3 @@ this._length -= 1;

}
return this._length;
};

@@ -524,38 +548,5 @@ LinkList.prototype.sort = function (cmp) {

/**
* @description Push an element to the front.
* @param element The element you want to push.
*/
LinkList.prototype.pushFront = function (element) {
this._length += 1;
var newHead = new LinkNode(element);
if (!this._head) {
this._head = this._tail = newHead;
this._tail._next = this._header;
this._header._pre = this._tail;
} else {
newHead._next = this._head;
this._head._pre = newHead;
this._head = newHead;
}
this._header._next = this._head;
this._head._pre = this._header;
};
/**
* @description Removes the first element.
*/
LinkList.prototype.popFront = function () {
if (!this._head) return;
this._length -= 1;
if (this._head === this._tail) {
this._head = this._tail = undefined;
this._header._pre = this._tail;
} else {
this._head = this._head._next;
this._head._pre = this._header;
}
this._header._next = this._head;
};
/**
* @description Merges two sorted lists.
* @param list The other list you want to merge (must be sorted).
* @param list - The other list you want to merge (must be sorted).
* @returns The size of list after merging.
* @example

@@ -568,28 +559,24 @@ * const linkA = new LinkList([1, 3, 5]);

var self = this;
if (!this._head) {
if (this._length === 0) {
list.forEach(function (el) {
self.pushBack(el);
});
return;
} else {
var curNode_1 = this._head;
list.forEach(function (el) {
while (curNode_1 !== self._header && curNode_1._value <= el) {
curNode_1 = curNode_1._next;
}
self._insertNode(el, curNode_1._pre);
});
}
return this._length;
};
LinkList.prototype.forEach = function (callback) {
var curNode = this._head;
list.forEach(function (element) {
while (curNode && curNode !== self._header && curNode._value <= element) {
curNode = curNode._next;
}
if (curNode === self._header) {
self.pushBack(element);
curNode = self._tail;
} else if (curNode === self._head) {
self.pushFront(element);
curNode = self._head;
} else {
self._length += 1;
var _pre = curNode._pre;
_pre._next = new LinkNode(element);
_pre._next._pre = _pre;
_pre._next._next = curNode;
curNode._pre = _pre._next;
}
});
var index = 0;
while (curNode !== this._header) {
callback(curNode._value, index++, this);
curNode = curNode._next;
}
};

@@ -602,3 +589,3 @@ LinkList.prototype[Symbol.iterator] = function () {

case 0:
if (!this._head) return [2 /*return*/];
if (this._length === 0) return [2 /*return*/];
curNode = this._head;

@@ -605,0 +592,0 @@ _a.label = 1;

/*!
* @js-sdsl/link-list v4.2.0-beta.1
* @js-sdsl/link-list v4.2.0
* https://github.com/js-sdsl/js-sdsl

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

*/
!function(t,i){"object"==typeof exports&&"undefined"!=typeof module?i(exports):"function"==typeof define&&define.amd?define(["exports"],i):i((t="undefined"!=typeof globalThis?globalThis:t||self).sdsl={})}(this,function(t){"use strict";var r=function(t,i){return(r=Object.setPrototypeOf||({__proto__:[]}instanceof Array?function(t,i){t.__proto__=i}:function(t,i){for(var o in i)Object.prototype.hasOwnProperty.call(i,o)&&(t[o]=i[o])}))(t,i)};function i(t,i){if("function"!=typeof i&&null!==i)throw new TypeError("Class extends value "+String(i)+" is not a constructor or null");function o(){this.constructor=t}r(t,i),t.prototype=null===i?Object.create(i):(o.prototype=i.prototype,new o)}function o(r,e){var n,s,h,u={label:0,sent:function(){if(1&h[0])throw h[1];return h[1]},trys:[],ops:[]},f={next:t(0),throw:t(1),return:t(2)};return"function"==typeof Symbol&&(f[Symbol.iterator]=function(){return this}),f;function t(o){return function(t){var i=[o,t];if(n)throw new TypeError("Generator is already executing.");for(;u=f&&i[f=0]?0:u;)try{if(n=1,s&&(h=2&i[0]?s.return:i[0]?s.throw||((h=s.return)&&h.call(s),0):s.next)&&!(h=h.call(s,i[1])).done)return h;switch(s=0,(i=h?[2&i[0],h.value]:i)[0]){case 0:case 1:h=i;break;case 4:return u.label++,{value:i[1],done:!1};case 5:u.label++,s=i[1],i=[0];continue;case 7:i=u.ops.pop(),u.trys.pop();continue;default:if(!(h=0<(h=u.trys).length&&h[h.length-1])&&(6===i[0]||2===i[0])){u=0;continue}if(3===i[0]&&(!h||i[1]>h[0]&&i[1]<h[3]))u.label=i[1];else if(6===i[0]&&u.label<h[1])u.label=h[1],h=i;else{if(!(h&&u.label<h[2])){h[2]&&u.ops.pop(),u.trys.pop();continue}u.label=h[2],u.ops.push(i)}}i=e.call(r,u)}catch(t){i=[6,t],s=0}finally{n=h=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}}}function e(t){this.iteratorType=t=void 0===t?0:t}function n(){this.i=0}n.prototype.size=function(){return this.i},n.prototype.empty=function(){return 0===this.i};i(u,s=n);var s,h=u;function u(){return null!==s&&s.apply(this,arguments)||this}i(p,f=h);var f,h=p;function p(){return null!==f&&f.apply(this,arguments)||this}var c,a=function(t){this.t=void 0,this.h=void 0,this.u=void 0,this.t=t},l=(i(v,c=e),Object.defineProperty(v.prototype,"pointer",{get:function(){if(this.o===this.L)throw new RangeError("LinkList iterator access denied!");return this.o.t},set:function(t){if(this.o===this.L)throw new RangeError("LinkList iterator access denied!");this.o.t=t},enumerable:!1,configurable:!0}),v.prototype.equals=function(t){return this.o===t.o},v.prototype.copy=function(){return new v(this.o,this.L,this.iteratorType)},v);function v(t,i,o){o=c.call(this,o)||this;return o.o=t,o.L=i,0===o.iteratorType?(o.pre=function(){if(this.o.h===this.L)throw new RangeError("LinkList iterator access denied!");return this.o=this.o.h,this},o.next=function(){if(this.o===this.L)throw new RangeError("LinkList iterator access denied!");return this.o=this.o.u,this}):(o.pre=function(){if(this.o.u===this.L)throw new RangeError("LinkList iterator access denied!");return this.o=this.o.u,this},o.next=function(){if(this.o===this.L)throw new RangeError("LinkList iterator access denied!");return this.o=this.o.h,this}),o}i(L,y=h),L.prototype.clear=function(){this.i=0,this.l=this.v=void 0,this.L.h=this.L.u=void 0},L.prototype.begin=function(){return new l(this.l||this.L,this.L)},L.prototype.end=function(){return new l(this.L,this.L)},L.prototype.rBegin=function(){return new l(this.v||this.L,this.L,1)},L.prototype.rEnd=function(){return new l(this.L,this.L,1)},L.prototype.front=function(){return this.l?this.l.t:void 0},L.prototype.back=function(){return this.v?this.v.t:void 0},L.prototype.forEach=function(t){if(this.i)for(var i=this.l,o=0;i!==this.L;)t(i.t,o++,this),i=i.u},L.prototype.getElementByPos=function(t){if(t<0||t>this.i-1)throw new RangeError;for(var i=this.l;t--;)i=i.u;return i.t},L.prototype.eraseElementByPos=function(t){if(t<0||t>this.i-1)throw new RangeError;if(0===t)this.popFront();else if(t===this.i-1)this.popBack();else{for(var i=this.l;t--;)i=i.u;var o=i.h,r=i.u;(r.h=o).u=r,--this.i}},L.prototype.eraseElementByValue=function(t){for(;this.l&&this.l.t===t;)this.popFront();for(;this.v&&this.v.t===t;)this.popBack();if(this.l)for(var i,o,r=this.l;r!==this.L;)r.t===t&&(i=r.h,((o=r.u).h=i).u=o,--this.i),r=r.u},L.prototype.eraseElementByIterator=function(t){var i,o=t.o;if(o===this.L)throw new RangeError("Invalid iterator");return t=t.next(),this.l===o?this.popFront():this.v===o?this.popBack():(i=o.h,((o=o.u).h=i).u=o,--this.i),t},L.prototype.pushBack=function(t){this.i+=1;t=new a(t);this.v?((this.v.u=t).h=this.v,this.v=t):(this.l=this.v=t,this.L.u=this.l,this.l.h=this.L),this.v.u=this.L,this.L.h=this.v},L.prototype.popBack=function(){this.v&&(--this.i,this.l===this.v?(this.l=this.v=void 0,this.L.u=void 0):(this.v=this.v.h,this.v.u=this.L),this.L.h=this.v)},L.prototype.setElementByPos=function(t,i){if(t<0||t>this.i-1)throw new RangeError;for(var o=this.l;t--;)o=o.u;o.t=i},L.prototype.insert=function(t,i,o){if(void 0===o&&(o=1),t<0||t>this.i)throw new RangeError;if(!(o<=0))if(0===t)for(;o--;)this.pushFront(i);else if(t===this.i)for(;o--;)this.pushBack(i);else{for(var r=this.l,e=1;e<t;++e)r=r.u;var n=r.u;for(this.i+=o;o--;)r.u=new a(i),r=(r.u.h=r).u;(r.u=n).h=r}},L.prototype.find=function(t){if(this.l)for(var i=this.l;i!==this.L;){if(i.t===t)return new l(i,this.L);i=i.u}return this.end()},L.prototype.reverse=function(){if(!(this.i<=1))for(var t=this.l,i=this.v,o=0;o<<1<this.i;){var r=t.t;t.t=i.t,i.t=r,t=t.u,i=i.h,o+=1}},L.prototype.unique=function(){if(!(this.i<=1))for(var t=this.l;t!==this.L;){for(var i=t;i.u&&i.t===i.u.t;)i=i.u,--this.i;t.u=i.u,t=(t.u.h=t).u}},L.prototype.sort=function(t){var i,o;this.i<=1||(i=[],this.forEach(function(t){i.push(t)}),i.sort(t),o=this.l,i.forEach(function(t){o.t=t,o=o.u}))},L.prototype.pushFront=function(t){this.i+=1;t=new a(t);this.l?(t.u=this.l,this.l.h=t,this.l=t):(this.l=this.v=t,this.v.u=this.L,this.L.h=this.v),this.L.u=this.l,this.l.h=this.L},L.prototype.popFront=function(){this.l&&(--this.i,this.l===this.v?(this.l=this.v=void 0,this.L.h=this.v):(this.l=this.l.u,this.l.h=this.L),this.L.u=this.l)},L.prototype.merge=function(t){var o,r=this;this.l?(o=this.l,t.forEach(function(t){for(;o&&o!==r.L&&o.t<=t;)o=o.u;var i;o===r.L?(r.pushBack(t),o=r.v):o===r.l?(r.pushFront(t),o=r.l):(r.i+=1,(i=o.h).u=new a(t),((i.u.h=i).u.u=o).h=i.u)})):t.forEach(function(t){r.pushBack(t)})},L.prototype[Symbol.iterator]=function(){return function(){var i;return o(this,function(t){switch(t.label){case 0:if(!this.l)return[2];i=this.l,t.label=1;case 1:return i===this.L?[3,3]:[4,i.t];case 2:return t.sent(),i=i.u,[3,1];case 3:return[2]}})}.bind(this)()};var y,h=L;function L(t){void 0===t&&(t=[]);var i=y.call(this)||this,o=(i.L=new a,i.l=void 0,i.v=void 0,i);return t.forEach(function(t){o.pushBack(t)}),i}t.LinkList=h,Object.defineProperty(t,"k",{value:!0})});
!function(t,i){"object"==typeof exports&&"undefined"!=typeof module?i(exports):"function"==typeof define&&define.amd?define(["exports"],i):i((t="undefined"!=typeof globalThis?globalThis:t||self).sdsl={})}(this,function(t){"use strict";var n=function(t,i){return(n=Object.setPrototypeOf||({__proto__:[]}instanceof Array?function(t,i){t.__proto__=i}:function(t,i){for(var r in i)Object.prototype.hasOwnProperty.call(i,r)&&(t[r]=i[r])}))(t,i)};function i(t,i){if("function"!=typeof i&&null!==i)throw new TypeError("Class extends value "+String(i)+" is not a constructor or null");function r(){this.constructor=t}n(t,i),t.prototype=null===i?Object.create(i):(r.prototype=i.prototype,new r)}function r(n,e){var o,s,h,u={label:0,sent:function(){if(1&h[0])throw h[1];return h[1]},trys:[],ops:[]},f={next:t(0),throw:t(1),return:t(2)};return"function"==typeof Symbol&&(f[Symbol.iterator]=function(){return this}),f;function t(r){return function(t){var i=[r,t];if(o)throw new TypeError("Generator is already executing.");for(;u=f&&i[f=0]?0:u;)try{if(o=1,s&&(h=2&i[0]?s.return:i[0]?s.throw||((h=s.return)&&h.call(s),0):s.next)&&!(h=h.call(s,i[1])).done)return h;switch(s=0,(i=h?[2&i[0],h.value]:i)[0]){case 0:case 1:h=i;break;case 4:return u.label++,{value:i[1],done:!1};case 5:u.label++,s=i[1],i=[0];continue;case 7:i=u.ops.pop(),u.trys.pop();continue;default:if(!(h=0<(h=u.trys).length&&h[h.length-1])&&(6===i[0]||2===i[0])){u=0;continue}if(3===i[0]&&(!h||i[1]>h[0]&&i[1]<h[3]))u.label=i[1];else if(6===i[0]&&u.label<h[1])u.label=h[1],h=i;else{if(!(h&&u.label<h[2])){h[2]&&u.ops.pop(),u.trys.pop();continue}u.label=h[2],u.ops.push(i)}}i=e.call(n,u)}catch(t){i=[6,t],s=0}finally{o=h=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}}}o.prototype.equals=function(t){return this.t===t.t};var e=o;function o(t){this.iteratorType=t=void 0===t?0:t}function s(){this.i=0}Object.defineProperty(s.prototype,"length",{get:function(){return this.i},enumerable:!1,configurable:!0}),s.prototype.size=function(){return this.i},s.prototype.empty=function(){return 0===this.i};i(f,h=s);var h,u=f;function f(){return null!==h&&h.apply(this,arguments)||this}i(c,p=u);var p,u=c;function c(){return null!==p&&p.apply(this,arguments)||this}function a(){throw new RangeError("Iterator access denied!")}i(v,l=e),Object.defineProperty(v.prototype,"pointer",{get:function(){return this.t===this.h&&a(),this.t.L},set:function(t){this.t===this.h&&a(),this.t.L=t},enumerable:!1,configurable:!0}),v.prototype.copy=function(){return new v(this.t,this.h,this.iteratorType)};var l,y=v;function v(t,i,r){r=l.call(this,r)||this;return r.t=t,r.h=i,0===r.iteratorType?(r.pre=function(){return this.t.o===this.h&&a(),this.t=this.t.o,this},r.next=function(){return this.t===this.h&&a(),this.t=this.t.u,this}):(r.pre=function(){return this.t.u===this.h&&a(),this.t=this.t.u,this},r.next=function(){return this.t===this.h&&a(),this.t=this.t.o,this}),r}i(d,b=u),d.prototype.k=function(t){var i=t.o,r=t.u;(i.u=r).o=i,t===this.l&&(this.l=r),t===this.v&&(this.v=i),--this.i},d.prototype._=function(t,i){var r=i.u,t={L:t,o:i,u:r};i.u=t,r.o=t,i===this.h&&(this.l=t),r===this.h&&(this.v=t),this.i+=1},d.prototype.clear=function(){this.i=0,this.l=this.v=this.h.o=this.h.u=this.h},d.prototype.begin=function(){return new y(this.l,this.h)},d.prototype.end=function(){return new y(this.h,this.h)},d.prototype.rBegin=function(){return new y(this.v,this.h,1)},d.prototype.rEnd=function(){return new y(this.h,this.h,1)},d.prototype.front=function(){return this.l.L},d.prototype.back=function(){return this.v.L},d.prototype.getElementByPos=function(t){if(t<0||t>this.i-1)throw new RangeError;for(var i=this.l;t--;)i=i.u;return i.L},d.prototype.eraseElementByPos=function(t){if(t<0||t>this.i-1)throw new RangeError;for(var i=this.l;t--;)i=i.u;return this.k(i),this.i},d.prototype.eraseElementByValue=function(t){for(var i=this.l;i!==this.h;)i.L===t&&this.k(i),i=i.u;return this.i},d.prototype.eraseElementByIterator=function(t){var i=t.t;return i===this.h&&a(),t=t.next(),this.k(i),t},d.prototype.pushBack=function(t){return this._(t,this.v),this.i},d.prototype.popBack=function(){var t;if(0!==this.i)return t=this.v.L,this.k(this.v),t},d.prototype.pushFront=function(t){return this._(t,this.h),this.i},d.prototype.popFront=function(){var t;if(0!==this.i)return t=this.l.L,this.k(this.l),t},d.prototype.setElementByPos=function(t,i){if(t<0||t>this.i-1)throw new RangeError;for(var r=this.l;t--;)r=r.u;r.L=i},d.prototype.insert=function(t,i,r){if(void 0===r&&(r=1),t<0||t>this.i)throw new RangeError;if(!(r<=0))if(0===t)for(;r--;)this.pushFront(i);else if(t===this.i)for(;r--;)this.pushBack(i);else{for(var n=this.l,e=1;e<t;++e)n=n.u;var o=n.u;for(this.i+=r;r--;)n.u={L:i,o:n},n=(n.u.o=n).u;(n.u=o).o=n}return this.i},d.prototype.find=function(t){for(var i=this.l;i!==this.h;){if(i.L===t)return new y(i,this.h);i=i.u}return this.end()},d.prototype.reverse=function(){if(!(this.i<=1))for(var t=this.l,i=this.v,r=0;r<<1<this.i;){var n=t.L;t.L=i.L,i.L=n,t=t.u,i=i.o,r+=1}},d.prototype.unique=function(){if(!(this.i<=1))for(var t=this.l;t!==this.h;){for(var i=t;i.u!==this.h&&i.L===i.u.L;)i=i.u,--this.i;t.u=i.u,t=(t.u.o=t).u}return this.i},d.prototype.sort=function(t){var i,r;this.i<=1||(i=[],this.forEach(function(t){i.push(t)}),i.sort(t),r=this.l,i.forEach(function(t){r.L=t,r=r.u}))},d.prototype.merge=function(t){var i,r=this;return 0===this.i?t.forEach(function(t){r.pushBack(t)}):(i=this.l,t.forEach(function(t){for(;i!==r.h&&i.L<=t;)i=i.u;r._(t,i.o)})),this.i},d.prototype.forEach=function(t){for(var i=this.l,r=0;i!==this.h;)t(i.L,r++,this),i=i.u},d.prototype[Symbol.iterator]=function(){return function(){var i;return r(this,function(t){switch(t.label){case 0:if(0===this.i)return[2];i=this.l,t.label=1;case 1:return i===this.h?[3,3]:[4,i.L];case 2:return t.sent(),i=i.u,[3,1];case 3:return[2]}})}.bind(this)()};var b,e=d;function d(t){void 0===t&&(t=[]);var i=b.call(this)||this,r=(i.h={},i.l=i.v=i.h.o=i.h.u=i.h,i);return t.forEach(function(t){r.pushBack(t)}),i}t.LinkList=e,Object.defineProperty(t,"p",{value:!0})});
//# sourceMappingURL=link-list.min.js.map
{
"name": "@js-sdsl/link-list",
"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

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