BinarySearchTree
Class TemplatePrototype
C++
template <typename T, typename Compare = std::less<T>>
class BinarySearchTree;
Description
Stores unique values in comparator order using a plain Binary Search Tree with smart-pointer-managed nodes.
Parameters
| Parameter | Description |
|---|---|
T | Stored value type. |
Compare | Strict weak ordering used to compare values. |
Return value
Not applicable.
Complexity
| Operation | Cost |
|---|---|
| Empty object creation | O(1) |
Example
C++
BinarySearchTree<int> tree;
tree.insert(8);
tree.insert(3);
Notes
- This is not a self-balancing tree.
- Values are unique; equivalent insertions are ignored.