mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-09-09 00:30:36 +02:00
Tree::addBranch
- Now returns a pointer to the new node, for convenience. Throws on error.
This commit is contained in:
parent
e651f7f759
commit
f03d1af431
2 changed files with 6 additions and 2 deletions
|
@ -76,10 +76,14 @@ Tree* Tree::operator[] (const int branch)
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
void Tree::addBranch (Tree* branch)
|
Tree* Tree::addBranch (Tree* branch)
|
||||||
{
|
{
|
||||||
|
if (! branch)
|
||||||
|
throw "Failed to allocate memory for parse tree.";
|
||||||
|
|
||||||
branch->_trunk = this;
|
branch->_trunk = this;
|
||||||
_branches.push_back (branch);
|
_branches.push_back (branch);
|
||||||
|
return branch;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -42,7 +42,7 @@ public:
|
||||||
Tree& operator= (const Tree&);
|
Tree& operator= (const Tree&);
|
||||||
Tree* operator[] (const int);
|
Tree* operator[] (const int);
|
||||||
|
|
||||||
void addBranch (Tree*);
|
Tree* addBranch (Tree*);
|
||||||
void removeBranch (Tree*);
|
void removeBranch (Tree*);
|
||||||
void replaceBranch (Tree*, Tree*);
|
void replaceBranch (Tree*, Tree*);
|
||||||
int branches ();
|
int branches ();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue