h_end case
Vladimir Bauer
3 years ago
| 13 | 13 | h_iter |
| 14 | 14 | h_pop_all |
| 15 | 15 | h_fix |
| 16 | h_end | |
| 16 | 17 | ) |
| 17 | 18 | |
| 18 | 19 | type heapRequest struct { |
| 81 | 82 | close(data.iter) |
| 82 | 83 | case h_fix: |
| 83 | 84 | heap.Fix(&bHeap, req.data.(int)) |
| 85 | case h_end: | |
| 86 | close(m) | |
| 87 | data := req.data.(chan []*Bar) | |
| 88 | data <- bHeap | |
| 84 | 89 | } |
| 85 | 90 | } |
| 86 | 91 | } |
| 107 | 112 | func (m heapManager) fix(index int) { |
| 108 | 113 | m <- heapRequest{cmd: h_push, data: index} |
| 109 | 114 | } |
| 115 | ||
| 116 | func (m heapManager) end() []*Bar { | |
| 117 | data := make(chan []*Bar) | |
| 118 | m <- heapRequest{cmd: h_end, data: data} | |
| 119 | return <-data | |
| 120 | } | |