fix(front, back) -> undefined exception; feat(resize)

This commit is contained in:
2025-07-22 19:22:25 +03:00
parent f762717de5
commit 94ce32cff3
10 changed files with 1648 additions and 44 deletions

View File

@ -35,6 +35,16 @@ export class List {
return this._end.clone()
}
resize(size, value) {
if (this._size > size)
while (this._size !== size)
this.popBack()
else
while (this._size !== size)
this.pushBack(value)
}
_shiftRight(dest, generator) {
let prev, res, new_item, item = dest.deref()
@ -75,7 +85,7 @@ export class List {
}
}
List.from = function (obj) {
List.from = function(obj) {
const list = new List()
for (const value of obj) {
list.pushBack(value)
@ -98,6 +108,7 @@ export class ListItem {
}
export class ListIterator {
constructor(item) {
this._item = item
}
@ -130,4 +141,4 @@ export class ListIterator {
}
}
mixinClasses(ListIterator, BidirectionalIterator)
mixinClasses(ListIterator, BidirectionalIterator)