Rename insert() to set() to avoid confusion with std::map::insert()
[junction.git] / junction / ConcurrentMap_Grampa.h
index 27e18ff3a5b4f1297f4f6b53835f8d3ce72a00cd..c8fdc8d561e0b3f46c9e7e9aa56dd7e59f383262 100644 (file)
@@ -290,9 +290,9 @@ public:
             }
         }
 
-        // Constructor: Insert cell
+        // Constructor: Insert or find cell
         Mutator(ConcurrentMap_Grampa& map, Key key) : m_map(map), m_value(Value(ValueTraits::NullValue)) {
-            TURF_TRACE(ConcurrentMap_Grampa, 12, "[Mutator] insert constructor called", uptr(map.m_root.load(turf::Relaxed)),
+            TURF_TRACE(ConcurrentMap_Grampa, 12, "[Mutator] insertOrFind constructor called", uptr(map.m_root.load(turf::Relaxed)),
                        uptr(key));
             Hash hash = KeyTraits::hash(key);
             for (;;) {
@@ -300,7 +300,7 @@ public:
                     m_map.createInitialTable(Details::MinTableSize);
                 } else {
                     ureg overflowIdx;
-                    switch (Details::insert(hash, m_table, m_sizeMask, m_cell, overflowIdx)) { // Modifies m_cell
+                    switch (Details::insertOrFind(hash, m_table, m_sizeMask, m_cell, overflowIdx)) { // Modifies m_cell
                     case Details::InsertResult_InsertedNew: {
                         // We've inserted a new cell. Don't load m_cell->value.
                         return;
@@ -310,7 +310,7 @@ public:
                         m_value = m_cell->value.load(turf::Consume);
                         if (m_value == Value(ValueTraits::Redirect)) {
                             // We've encountered a Redirect value.
-                            TURF_TRACE(ConcurrentMap_Grampa, 13, "[Mutator] insert was redirected", uptr(m_table), uptr(m_value));
+                            TURF_TRACE(ConcurrentMap_Grampa, 13, "[Mutator] insertOrFind was redirected", uptr(m_table), uptr(m_value));
                             break; // Help finish the migration.
                         }
                         return; // Found an existing value
@@ -374,7 +374,7 @@ public:
                     TURF_UNUSED(exists);
                     m_value = Value(ValueTraits::NullValue);
                     ureg overflowIdx;
-                    switch (Details::insert(hash, m_table, m_sizeMask, m_cell, overflowIdx)) { // Modifies m_cell
+                    switch (Details::insertOrFind(hash, m_table, m_sizeMask, m_cell, overflowIdx)) { // Modifies m_cell
                     case Details::InsertResult_AlreadyFound:
                         m_value = m_cell->value.load(turf::Consume);
                         if (m_value == Value(ValueTraits::Redirect)) {
@@ -448,7 +448,7 @@ public:
         }
     };
 
-    Mutator insert(Key key) {
+    Mutator insertOrFind(Key key) {
         return Mutator(*this, key);
     }
 
@@ -478,7 +478,7 @@ public:
         }
     }
 
-    Value insert(Key key, Value desired) {
+    Value set(Key key, Value desired) {
         Mutator iter(*this, key);
         return iter.exchangeValue(desired);
     }