Add ExpressionGraph::Erase(ExpressionId)

Add the function ExpressionGraph::Erase and a test-case for it.
Erase removes the given expression from the graph by shifting
all later expressions to the front. Indices and references
are updated accordingly.

Change-Id: Ic0449ccf28b369600fd2959a7e2a919d47f4cbe3
This commit is contained in:
Darius Rueckert
2020-02-07 17:18:46 +01:00
parent c8e35e19fd
commit d82de91b88
3 changed files with 60 additions and 0 deletions
@@ -64,6 +64,12 @@ class ExpressionGraph {
int Size() const { return expressions_.size(); }
// Erases the expression at "location". All expression after "location" are
// moved by one element to the front. References to moved expressions are
// updated. Removing an expression that is still referenced somewhere is
// undefined behaviour.
void Erase(ExpressionId location);
// Insert a new expression at "location" into the graph. All expression
// after "location" are moved by one element to the back. References to
// moved expressions are updated.