The Tree
class implements a generic binary tree data structure.
Its purpose is to work as a back-end for more structured trees,
such as a red-black tree, a kd-tree, or an expression tree; it
is meant as a reusable low-level component for a library
writer.
Implementing a generic binary tree well is, perhaps surprisingly, non-trivial. Failing to find certain design strategies leads to implementation- and user-code which contains accidental complexity, is prone to errors, has linear time-complexity where constant time-complexity would suffice, and can not be used with iterators. For a discussion of the different design options, see the discussion here.
Here we will present a generic binary tree data structure which