let fixedPriorityQueue = new FixedPriorityQueue()
expect(fixedPriorityQueue.start).toBe(0)
expect(fixedPriorityQueue.size).toBe(0)
- expect(fixedPriorityQueue.maxSize).toBe(0)
expect(fixedPriorityQueue.nodeArray).toBeInstanceOf(Array)
expect(fixedPriorityQueue.capacity).toBe(defaultQueueSize)
fixedPriorityQueue = new FixedPriorityQueue(2)
expect(fixedPriorityQueue.start).toBe(0)
expect(fixedPriorityQueue.size).toBe(0)
- expect(fixedPriorityQueue.maxSize).toBe(0)
expect(fixedPriorityQueue.nodeArray).toBeInstanceOf(Array)
expect(fixedPriorityQueue.capacity).toBe(2)
})
let rtSize = fixedPriorityQueue.enqueue(1)
expect(fixedPriorityQueue.start).toBe(0)
expect(fixedPriorityQueue.size).toBe(1)
- expect(fixedPriorityQueue.maxSize).toBe(1)
expect(rtSize).toBe(fixedPriorityQueue.size)
expect(fixedPriorityQueue.nodeArray).toMatchObject([
{ data: 1, priority: 0 }
rtSize = fixedPriorityQueue.enqueue(2)
expect(fixedPriorityQueue.start).toBe(0)
expect(fixedPriorityQueue.size).toBe(2)
- expect(fixedPriorityQueue.maxSize).toBe(2)
expect(rtSize).toBe(fixedPriorityQueue.size)
expect(fixedPriorityQueue.nodeArray).toMatchObject([
{ data: 1, priority: 0 },
rtSize = fixedPriorityQueue.enqueue(3)
expect(fixedPriorityQueue.start).toBe(0)
expect(fixedPriorityQueue.size).toBe(3)
- expect(fixedPriorityQueue.maxSize).toBe(3)
expect(rtSize).toBe(fixedPriorityQueue.size)
expect(fixedPriorityQueue.nodeArray).toMatchObject([
{ data: 1, priority: 0 },
rtSize = fixedPriorityQueue.enqueue(3, -1)
expect(fixedPriorityQueue.start).toBe(0)
expect(fixedPriorityQueue.size).toBe(4)
- expect(fixedPriorityQueue.maxSize).toBe(4)
expect(rtSize).toBe(fixedPriorityQueue.size)
expect(fixedPriorityQueue.nodeArray).toMatchObject([
{ data: 3, priority: -1 },
rtSize = fixedPriorityQueue.enqueue(1, 1)
expect(fixedPriorityQueue.start).toBe(0)
expect(fixedPriorityQueue.size).toBe(5)
- expect(fixedPriorityQueue.maxSize).toBe(5)
expect(rtSize).toBe(fixedPriorityQueue.size)
expect(fixedPriorityQueue.nodeArray).toMatchObject([
{ data: 3, priority: -1 },
fixedPriorityQueue.enqueue(3)
expect(fixedPriorityQueue.start).toBe(0)
expect(fixedPriorityQueue.size).toBe(3)
- expect(fixedPriorityQueue.maxSize).toBe(3)
expect(fixedPriorityQueue.capacity).toBe(queueSize)
let rtItem = fixedPriorityQueue.dequeue()
expect(fixedPriorityQueue.start).toBe(1)
expect(fixedPriorityQueue.size).toBe(2)
- expect(fixedPriorityQueue.maxSize).toBe(3)
expect(rtItem).toBe(2)
expect(fixedPriorityQueue.nodeArray).toMatchObject([
{ data: 2, priority: -1 },
rtItem = fixedPriorityQueue.dequeue()
expect(fixedPriorityQueue.start).toBe(2)
expect(fixedPriorityQueue.size).toBe(1)
- expect(fixedPriorityQueue.maxSize).toBe(3)
expect(rtItem).toBe(1)
expect(fixedPriorityQueue.nodeArray).toMatchObject([
{ data: 2, priority: -1 },
rtItem = fixedPriorityQueue.dequeue()
expect(fixedPriorityQueue.start).toBe(3)
expect(fixedPriorityQueue.size).toBe(0)
- expect(fixedPriorityQueue.maxSize).toBe(3)
expect(rtItem).toBe(3)
expect(fixedPriorityQueue.nodeArray).toMatchObject([
{ data: 2, priority: -1 },
rtItem = fixedPriorityQueue.dequeue()
expect(fixedPriorityQueue.start).toBe(3)
expect(fixedPriorityQueue.size).toBe(0)
- expect(fixedPriorityQueue.maxSize).toBe(3)
expect(rtItem).toBe(undefined)
expect(fixedPriorityQueue.nodeArray).toMatchObject([
{ data: 2, priority: -1 },
const fixedPriorityQueue = new FixedPriorityQueue()
fixedPriorityQueue.start = 1
fixedPriorityQueue.size = 2
- fixedPriorityQueue.maxSize = 2
fixedPriorityQueue.nodeArray = [
{ data: 2, priority: 0 },
{ data: 3, priority: 0 }
fixedPriorityQueue.clear()
expect(fixedPriorityQueue.start).toBe(0)
expect(fixedPriorityQueue.size).toBe(0)
- expect(fixedPriorityQueue.maxSize).toBe(0)
expect(fixedPriorityQueue.nodeArray).toMatchObject([
{ data: 2, priority: 0 },
{ data: 3, priority: 0 }