// Success! This is the one we want.
else if (position >= (int)components.size()) {
- return current;
+ return (current->getAttribute(SGPropertyNode::REMOVED) ? 0 : current);
}
// Empty component means root.
if (keep) {
_removedChildren.push_back(node);
}
+ _path_cache->erase(name); // EMH - TODO: Take "index" into account!
node->setAttribute(REMOVED, true);
node->clearValue();
ret = node;
vector<PathComponent> components;
parse_path(relative_path, components);
if (components.size() > 0)
- components[components.size()-1].index = index;
+ components.back().index = index;
return find_node(this, components, 0, create);
}
}
}
+void
+SGPropertyNode::hash_table::bucket::erase (const char * key)
+{
+ int i;
+ for (i = 0; i < _length; i++) {
+ if (!strcmp(_entries[i]->get_key(), key))
+ break;
+ }
+
+ if (i < _length) {
+ for (++i; i < _length; i++) {
+ _entries[i-1] = _entries[i];
+ }
+ _length--;
+ }
+}
+
SGPropertyNode::hash_table::hash_table ()
: _data_length(0),
e->set_value(value);
}
+void
+SGPropertyNode::hash_table::erase (const char * key)
+{
+ if (_data_length == 0)
+ return;
+ unsigned int index = hashcode(key) % _data_length;
+ if (_data[index] == 0)
+ return;
+ _data[index]->erase(key);
+}
+
unsigned int
SGPropertyNode::hash_table::hashcode (const char * key)
{