@cloud-copilot/iam-lens
Version:
Visibility in IAM in and across AWS accounts
36 lines • 901 B
JavaScript
export class RingQueue {
constructor(capacity) {
this.head = 0;
this.tail = 0;
this.capacity = capacity;
this.buffer = new Array(capacity);
this.size = 0;
}
enqueue(item) {
if (this.size >= this.capacity)
return false;
this.buffer[this.tail] = item;
this.tail = (this.tail + 1) % this.capacity;
this.size++;
return true;
}
dequeue() {
if (this.size === 0)
return undefined;
const item = this.buffer[this.head];
this.buffer[this.head] = undefined;
this.head = (this.head + 1) % this.capacity;
this.size--;
return item;
}
isEmpty() {
return this.size === 0;
}
length() {
return this.size;
}
isFull() {
return this.size === this.capacity;
}
}
//# sourceMappingURL=RingQueue.js.map