All returns an iterator that loops over all task key-value pairs in the order specified by the sorter.
(sorter sort.Sorter)
| 78 | // All returns an iterator that loops over all task key-value pairs in the order |
| 79 | // specified by the sorter. |
| 80 | func (t *Tasks) All(sorter sort.Sorter) iter.Seq2[string, *Task] { |
| 81 | if t == nil || t.om == nil { |
| 82 | return func(yield func(string, *Task) bool) {} |
| 83 | } |
| 84 | if sorter == nil { |
| 85 | return t.om.AllFromFront() |
| 86 | } |
| 87 | return func(yield func(string, *Task) bool) { |
| 88 | for _, key := range sorter(slices.Collect(t.om.Keys()), nil) { |
| 89 | el := t.om.GetElement(key) |
| 90 | if !yield(el.Key, el.Value) { |
| 91 | return |
| 92 | } |
| 93 | } |
| 94 | } |
| 95 | } |
| 96 | |
| 97 | // Keys returns an iterator that loops over all task keys in the order specified |
| 98 | // by the sorter. |