-
-
Notifications
You must be signed in to change notification settings - Fork 99
Closed
Description
using package v0.39.7
const q = new CircularBuffer<boolean>(Array, 2)
{
q.push(true)
q.push(true)
q.push(true)
// q.push(true)
}
q.push(false)
q.push(true)
console.log(q.toArray()) // [false, true]
console.log(q.peekFirst()) // false
console.log(q.peekLast()) // undefined
const q = new CircularBuffer<boolean>(Array, 2)
{
q.push(true)
q.push(true)
q.push(true)
q.push(true) // <--- this line is uncommented
}
q.push(false)
q.push(true)
console.log(q.toArray()) // [false, true]
console.log(q.peekFirst()) // false
console.log(q.peekLast()) // true
Maybe https://github.com/Yomguithereal/mnemonist/blob/0.39.7/fixed-deque.js#L138-L139 should be ?
-if (index > this.capacity)
+if (index >= this.capacity)
index -= this.capacity;
or I got something misunderstanding ?
Metadata
Metadata
Assignees
Labels
No labels