Closed magicdawn closed 8 months ago
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 ?
You are right indeed. I fixed some other stuff related to FixedDeque & CircularBuffer. This is now available in v0.39.8, thanks @magicdawn.
FixedDeque
CircularBuffer
using package v0.39.7
Maybe https://github.com/Yomguithereal/mnemonist/blob/0.39.7/fixed-deque.js#L138-L139 should be ?
or I got something misunderstanding ?