The Tree class

The C++ standard library hold a set of container classes for arrays, lists, vectors, sets, and maps. However, there is no class for a tree structure. Therefore, the Tree class has been added to Small Windows. A tree is made up of a set of nodes, among which, one is the root node. Each node holds a (possibly empty) list of child nodes:

Tree.h

namespace SmallWindows { 
  template <class NodeType> 
  class Tree { 
    public: 
      Tree(); 
      Tree(NodeType nodeValue, 
           initializer_list<Tree<NodeType>*> childList = {}); 
      Tree(const Tree& tree); 
      Tree& operator=(const Tree& tree); 
      void Init(const Tree& tree); 
      ~Tree(); 

The tree can be written to, and read from, a file stream or the clipboard:

 bool WriteTreeToStream(ostream& outStream) const; bool ReadTreeFromStream(istream& ...

Get C++ Windows Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.