nav tabs on admin dashboard

This commit is contained in:
2019-03-07 00:20:34 -06:00
parent f73d6ae228
commit e4f473f376
11661 changed files with 216240 additions and 1544253 deletions

View File

@@ -1,42 +1,46 @@
"use strict";
module.exports = class Queue {
/**
* @template T
*/
class Queue {
/**
* @param {Iterable<T>=} items The initial elements.
*/
constructor(items) {
this.first = null;
this.last = null;
this.length = 0;
if(items) {
for(const item of items) {
this.enqueue(item);
}
}
/** @private @type {Set<T>} */
this.set = new Set(items);
/** @private @type {Iterator<T>} */
this.iterator = this.set[Symbol.iterator]();
}
/**
* Returns the number of elements in this queue.
* @returns {number} The number of elements in this queue.
*/
get length() {
return this.set.size;
}
/**
* Appends the specified element to this queue.
* @param {T} item The element to add.
* @returns {void}
*/
enqueue(item) {
const first = this.first;
const node = {
item,
next: null
};
if(first === null) {
this.last = node;
} else {
first.next = node;
}
this.first = node;
this.length++;
this.set.add(item);
}
/**
* Retrieves and removes the head of this queue.
* @returns {T | undefined} The head of the queue of `undefined` if this queue is empty.
*/
dequeue() {
const last = this.last;
if(last === null)
return undefined;
const next = last.next;
if(next === null) {
this.first = null;
}
this.last = next;
this.length--;
return last.item;
const result = this.iterator.next();
if (result.done) return undefined;
this.set.delete(result.value);
return result.value;
}
};
}
module.exports = Queue;