2
0
mirror of https://github.com/boostorg/log.git synced 2026-02-11 11:52:20 +00:00

Fixed incorrect element insertion.

The inserted attributes and attribute values could sometimes be left not-findable by find() method and other methods that rely on it. The elements were still obtainable through iteration.
This commit is contained in:
Andrey Semashev
2014-06-21 20:54:11 +04:00
parent c26d7c0c45
commit 4b137ed869
3 changed files with 140 additions and 26 deletions

View File

@@ -391,27 +391,34 @@ private:
p = new node(key, data, true);
}
node_list::iterator it;
if (b.first == NULL)
{
// The bucket is empty
b.first = b.last = p;
m_Nodes.push_back(*p);
it = m_Nodes.end();
}
else if (where == b.first)
{
// The new element should become the first element of the bucket
it = m_Nodes.iterator_to(*where);
b.first = p;
}
else if (where == b.last && key.id() > where->m_Value.first.id())
{
// The new element should become the last element of the bucket
node_list::iterator it = m_Nodes.iterator_to(*where);
it = m_Nodes.iterator_to(*where);
++it;
m_Nodes.insert(it, *p);
b.last = p;
}
else
{
// The new element should be within the bucket
node_list::iterator it = m_Nodes.iterator_to(*where);
m_Nodes.insert(it, *p);
it = m_Nodes.iterator_to(*where);
}
m_Nodes.insert(it, *p);
return p;
}