| 140 | } |
| 141 | |
| 142 | void SimNameDictionary::remove(SimObject* obj) |
| 143 | { |
| 144 | if (!obj || !obj->getName()) |
| 145 | return; |
| 146 | |
| 147 | Mutex::lockMutex(mutex); |
| 148 | #ifndef USE_NEW_SIMDICTIONARY |
| 149 | SimObject **walk = &hashTable[HashPointer(obj->getName()) % hashTableSize]; |
| 150 | while (*walk) |
| 151 | { |
| 152 | if (*walk == obj) |
| 153 | { |
| 154 | *walk = obj->nextNameObject; |
| 155 | obj->nextNameObject = nullptr; |
| 156 | hashEntryCount--; |
| 157 | |
| 158 | Mutex::unlockMutex(mutex); |
| 159 | return; |
| 160 | } |
| 161 | walk = &((*walk)->nextNameObject); |
| 162 | } |
| 163 | #else |
| 164 | const char* name = obj->objectName; |
| 165 | if (root.find(name) != root.end()) |
| 166 | root.erase(name); |
| 167 | #endif |
| 168 | Mutex::unlockMutex(mutex); |
| 169 | } |
| 170 | |
| 171 | //---------------------------------------------------------------------------- |
| 172 | |