SOL9 2.0 Class: BinaryTree

 SOL9 C++ Class Library  SOL9 Samples  SOL9 Tutorial  SOL9 FAQ  SOL9 ClassTree 

Source code

/*
 * BinaryTree.h 
 * Copyright (c) 2011 Antillia.com TOSHIYUKI ARAI. ALL RIGHTS RESERVED. 
 */


// SOL++2000
#pragma once

#include <sol\Object.h>
#include <sol\BinaryNode.h>

namespace SOL {

class BinaryTree :public Object {
private:
    BinaryNode*     root;
  
public:
    BinaryTree(BinaryNode* root1 = NULL) { root = root1; }
    
    ~BinaryTree() { delete root; }

    BinaryNode*    search(const TCHAR* name) {
        if(root) {
                return root->search(name);
        } else { 
                return NULL;
        }
    }

    BinaryNode*     getRoot() { return root; }

    void    print() { if (root) root -> print(); }

    void     setRoot(BinaryNode* node) { root = node; }
};

}



Last modified: 1 Feb 2012

Copyright (c) 2009-2012 Antillia.com ALL RIGHTS RESERVED.