Are there standard for Binary Search Tree methods?
An answer to this question on Stack Overflow.
Question
I am implementing a BST in C++ and I implemented Get(), Add(), Remove() and Contains() methods. I know that some containers have standards such as a stack has push() and pop() methods. But I couldn't find any document about BST's standard methods?
Are there standard methods (like an interface) or is it up to us?
Answer
Ultimately, it is up to you. C++ does not define a standard interface for anything.
That said the STL does recycle accessor names.
Set and map are likely the most similar data structures to your BST.
Set uses insert(), count() tells you if a set contains an item, erase() removes an item.
Map uses operator[] (the square brackets) and at() to access and set elements, in addition to offering insert(). erase() is used to remove an element.
So, in this sense, there's some kind of standardization, but it's specific to the STL and those who emulate it. However, use of the STL is wide-spread, so if there was anything you'd want to emulate, that would be it.