mirror of
https://github.com/trekhleb/javascript-algorithms.git
synced 2025-12-19 08:59:05 +08:00
Make it possible to add objects to LinkedList.
This commit is contained in:
@@ -18,11 +18,15 @@ export default class Queue {
|
||||
}
|
||||
|
||||
enqueue(value) {
|
||||
this.linkedList.append({ value });
|
||||
this.linkedList.append(value);
|
||||
}
|
||||
|
||||
dequeue() {
|
||||
const removedHead = this.linkedList.deleteHead();
|
||||
return removedHead ? removedHead.value : null;
|
||||
}
|
||||
|
||||
toString(callback) {
|
||||
return this.linkedList.toString(callback);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user