Init
This commit is contained in:
11
node_modules/sweet-collections/dist/queue/Queue.d.ts
generated
vendored
Normal file
11
node_modules/sweet-collections/dist/queue/Queue.d.ts
generated
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
export declare class Queue<T> {
|
||||
private head?;
|
||||
private tail?;
|
||||
private _size;
|
||||
push(...values: T[]): this;
|
||||
pop(_default?: T): T | undefined;
|
||||
peek(): T | undefined;
|
||||
isEmpty(): boolean;
|
||||
clear(): void;
|
||||
get size(): number;
|
||||
}
|
||||
48
node_modules/sweet-collections/dist/queue/Queue.js
generated
vendored
Normal file
48
node_modules/sweet-collections/dist/queue/Queue.js
generated
vendored
Normal file
@ -0,0 +1,48 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.Queue = void 0;
|
||||
class Queue {
|
||||
constructor() {
|
||||
this._size = 0;
|
||||
}
|
||||
push(...values) {
|
||||
for (const value of values) {
|
||||
const node = { value };
|
||||
if (this.tail) {
|
||||
this.tail.next = node;
|
||||
}
|
||||
this.tail = node;
|
||||
if (!this.head) {
|
||||
this.head = this.tail;
|
||||
}
|
||||
this._size++;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
pop(_default) {
|
||||
if (this.head) {
|
||||
const value = this.head.value;
|
||||
this.head = this.head.next;
|
||||
if (!this.head) {
|
||||
this.tail = undefined;
|
||||
}
|
||||
this._size--;
|
||||
return value;
|
||||
}
|
||||
return _default;
|
||||
}
|
||||
peek() {
|
||||
return this.head.value;
|
||||
}
|
||||
isEmpty() {
|
||||
return this.head === undefined;
|
||||
}
|
||||
clear() {
|
||||
this.head = this.tail = undefined;
|
||||
this._size = 0;
|
||||
}
|
||||
get size() {
|
||||
return this._size;
|
||||
}
|
||||
}
|
||||
exports.Queue = Queue;
|
||||
1
node_modules/sweet-collections/dist/queue/index.d.ts
generated
vendored
Normal file
1
node_modules/sweet-collections/dist/queue/index.d.ts
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
export * from './Queue';
|
||||
13
node_modules/sweet-collections/dist/queue/index.js
generated
vendored
Normal file
13
node_modules/sweet-collections/dist/queue/index.js
generated
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
||||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
__exportStar(require("./Queue"), exports);
|
||||
Reference in New Issue
Block a user