Contains finds the id, if it exists
(id string)
| 13 | |
| 14 | // Contains finds the id, if it exists |
| 15 | func (o *Objects) Contains(id string) (int, bool) { |
| 16 | o.mutex.RLock() |
| 17 | defer o.mutex.RUnlock() |
| 18 | |
| 19 | idx := sort.SearchStrings(o.ids, id) |
| 20 | |
| 21 | if idx == len(o.ids) || o.ids[idx] != id { |
| 22 | return -1, false |
| 23 | } |
| 24 | |
| 25 | return idx, true |
| 26 | } |
| 27 | |
| 28 | // Add adds the given object |
| 29 | func (o *Objects) Add(id string) bool { |