diff options
author | Bent Bisballe Nyeng <deva@aasimon.org> | 2020-06-27 11:37:27 +0200 |
---|---|---|
committer | Bent Bisballe Nyeng <deva@aasimon.org> | 2020-06-27 11:37:27 +0200 |
commit | d21701afe4230d633ae685ffeee6f5fb5a76f34d (patch) | |
tree | d91c68539a01757e1f350e3e53fdf36319ca126e /src/nodetree.cc | |
parent | 7198cd81e1db3c92f99a7079e7820a6cdc51c40a (diff) |
Check for existing ids in the tree when creating a new node.
Diffstat (limited to 'src/nodetree.cc')
-rw-r--r-- | src/nodetree.cc | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/nodetree.cc b/src/nodetree.cc index eac919e..a2499ea 100644 --- a/src/nodetree.cc +++ b/src/nodetree.cc @@ -101,11 +101,16 @@ nodeid_t NodeTree::createId() { nodeid = nextid++; } - while(id2node.find(nodeid) != id2node.end()); + while(hasId(nodeid)); return nodeid; } +bool NodeTree::hasId(nodeid_t nodeid) +{ + return id2node.find(nodeid) != id2node.end(); +} + static nodeid_t rootid = -1; NodeIdList NodeTree::insertAsChild(nodeid_t parentid, nodeid_t id, |