Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions deque.js
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,22 @@ Deque.prototype.get = function (index) {
return this[(this.front + index) & (this.capacity - 1)];
};

Deque.prototype.set = function (index, value) {
// Domain only includes integers
if (index !== (index | 0)) {
return;
}
// Support negative indicies
if (index < 0) {
index = index + this.length;
}
// Out of bounds
if (index < 0 || index >= this.length) {
return;
}
this[(this.front + index) & (this.capacity - 1)] = value;
};

Deque.prototype.indexOf = function (value, index) {
// Default start index at beginning
if (index == null) {
Expand Down