Reset clears the store and replaces the store data with a shallow copy of the provided newData.
(newData map[K]T)
| 27 | // Reset clears the store and replaces the store data with a |
| 28 | // shallow copy of the provided newData. |
| 29 | func (s *Store[K, T]) Reset(newData map[K]T) { |
| 30 | s.mu.Lock() |
| 31 | defer s.mu.Unlock() |
| 32 | |
| 33 | if len(newData) > 0 { |
| 34 | s.data = make(map[K]T, len(newData)) |
| 35 | for k, v := range newData { |
| 36 | s.data[k] = v |
| 37 | } |
| 38 | } else { |
| 39 | s.data = make(map[K]T) |
| 40 | } |
| 41 | |
| 42 | s.deleted = 0 |
| 43 | } |
| 44 | |
| 45 | // Length returns the current number of elements in the store. |
| 46 | func (s *Store[K, T]) Length() int { |
no outgoing calls