| … | … | @@ -211,13 +211,25 @@ public: |
| 211 | 211 | return the_set.size(); |
| 212 | 212 | } |
| 213 | 213 | |
| 214 | | std::set<Element, Compare> peek() const |
| 214 | /// Return entire contents of the container, as they are at just |
| 215 | /// this particular moment in time. |
| 216 | std::set<Element, Compare> snapshot() const |
| 215 | 217 | { |
| 216 | 218 | std::lock_guard<std::mutex> lock(the_mutex); |
| 217 | 219 | std::set<Element, Compare> copy(the_set); |
| 218 | 220 | return copy; |
| 219 | 221 | } |
| 220 | 222 | |
| 223 | /// Return one element, any element from the container, as it is |
| 224 | /// right now, at just this moment. |
| 225 | std::optional<Element> peek() const |
| 226 | { |
| 227 | std::lock_guard<std::mutex> lock(the_mutex); |
| 228 | if (the_set.empty()) |
| 229 | return std::nullopt; |
| 230 | return *the_set.begin(); |
| 231 | } |
| 232 | |
| 221 | 233 | /// Erase all elements from the container. |
| 222 | 234 | void clear() |
| 223 | 235 | { |