8#include <unordered_set>
17std::unordered_set<int32_t> g_assigned_ids;
26 g_assigned_ids.erase(id_);
30 return Get() == other.
Get();
34 return !(*
this == other);
37bool AXUniqueId::IsAssigned(
const int32_t
id)
const {
41int32_t AXUniqueId::GetNextAXUniqueId(
const int32_t max_id) {
42 static int32_t current_id = 0;
43 static bool has_wrapped =
false;
45 const int32_t prev_id = current_id;
47 if (current_id >= max_id) {
53 if (current_id == prev_id) {
54 BASE_LOG() <<
"There are over 2 billion available IDs, so the newly "
55 "created ID cannot be equal to the most recently created "
60 }
while (has_wrapped && IsAssigned(current_id));
62 g_assigned_ids.insert(current_id);
bool operator!=(const AXUniqueId &other) const
bool operator==(const AXUniqueId &other) const
bool Contains(const Container &container, const Value &value)