mirror of
https://github.com/onyx-and-iris/aoc2024.git
synced 2025-01-09 06:10:47 +00:00
add {heap}.IsEmpty() and use it to empty the block during write()
This commit is contained in:
parent
52541e7ca7
commit
abf7abf3ea
@ -124,7 +124,7 @@ func (d *disk) write() {
|
|||||||
allBlocks = append(allBlocks, d.fileblocks...)
|
allBlocks = append(allBlocks, d.fileblocks...)
|
||||||
|
|
||||||
for i := 0; i < numEmptyBlocks; i++ {
|
for i := 0; i < numEmptyBlocks; i++ {
|
||||||
for range d.emptyblocks[i].Len() {
|
for !d.emptyblocks[i].IsEmpty() {
|
||||||
allBlocks = append(allBlocks, heap.Pop(&d.emptyblocks[i]).(*block))
|
allBlocks = append(allBlocks, heap.Pop(&d.emptyblocks[i]).(*block))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,3 +25,7 @@ func (h *minHeap) Pop() interface{} {
|
|||||||
*h = old[:n-1]
|
*h = old[:n-1]
|
||||||
return x
|
return x
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (h *minHeap) IsEmpty() bool {
|
||||||
|
return h.Len() == 0
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user