Set sets the value of the task with the provided key to the provided value. If the task already exists, its value is updated. If the task does not exist, it is created.
(key string, value *Task)
| 64 | // If the task already exists, its value is updated. If the task does not exist, |
| 65 | // it is created. |
| 66 | func (tasks *Tasks) Set(key string, value *Task) bool { |
| 67 | if tasks == nil { |
| 68 | tasks = NewTasks() |
| 69 | } |
| 70 | if tasks.om == nil { |
| 71 | tasks.om = orderedmap.NewOrderedMap[string, *Task]() |
| 72 | } |
| 73 | defer tasks.mutex.Unlock() |
| 74 | tasks.mutex.Lock() |
| 75 | return tasks.om.Set(key, value) |
| 76 | } |
| 77 | |
| 78 | // All returns an iterator that loops over all task key-value pairs in the order |
| 79 | // specified by the sorter. |