mirror of
https://github.com/onyx-and-iris/aoc2024.git
synced 2026-04-09 02:23:36 +00:00
add {heap}.IsEmpty() and use it to empty the block during write()
This commit is contained in:
@@ -124,7 +124,7 @@ func (d *disk) write() {
|
||||
allBlocks = append(allBlocks, d.fileblocks...)
|
||||
|
||||
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))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,3 +25,7 @@ func (h *minHeap) Pop() interface{} {
|
||||
*h = old[:n-1]
|
||||
return x
|
||||
}
|
||||
|
||||
func (h *minHeap) IsEmpty() bool {
|
||||
return h.Len() == 0
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user