Back to index

plt-scheme  4.2.1
Public Member Functions | Static Public Member Functions | Public Attributes | Private Attributes
Tree Class Reference
Inheritance diagram for Tree:
Inheritance graph
[legend]
Collaboration diagram for Tree:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 Tree (int init_leaves)
virtual void Grow (int n)
virtual void Grow (char *command, char *&result)
void Graft (Tree *left, Tree *right)

Static Public Member Functions

static void Add (Tree *t)
static void Drop (Tree *t)

Public Attributes

Treeleft_branch
Treeright_branch
int leaves
voiduser_data

Private Attributes

int refcount

Detailed Description

Definition at line 107 of file tree.cxx.


Constructor & Destructor Documentation

Tree::Tree ( int  init_leaves) [inline]

Definition at line 124 of file tree.cxx.

                        {
    left_branch = right_branch = NULL;
    leaves = init_leaves;
    refcount = 1;
    user_data = NULL;
  }

Here is the caller graph for this function:


Member Function Documentation

static void Tree::Add ( Tree t) [inline, static]

Definition at line 182 of file tree.cxx.

                           {
    if (t)
      t->refcount++;
  }

Here is the caller graph for this function:

static void Tree::Drop ( Tree t) [inline, static]

Definition at line 186 of file tree.cxx.

                            {
    if (t) {
      t->refcount--;
      if (!t->refcount)
       delete t;
    }
  }

Here is the caller graph for this function:

void Tree::Graft ( Tree left,
Tree right 
) [inline]

Definition at line 164 of file tree.cxx.

Here is the call graph for this function:

Here is the caller graph for this function:

virtual void Tree::Grow ( int  n) [inline, virtual]

Reimplemented in mzTree.

Definition at line 133 of file tree.cxx.

                           {
    if (left_branch)
      left_branch->Grow(n);
    else
      left_branch = new Tree(n);
    if (right_branch)
      right_branch->Grow(n);
    else
      right_branch = new Tree(n);
  }

Here is the call graph for this function:

Here is the caller graph for this function:

virtual void Tree::Grow ( char *  command,
char *&  result 
) [inline, virtual]

Reimplemented in mzTree.

Definition at line 144 of file tree.cxx.

                                                  {
    if (!strcmp(command, "sunshine")) {
      if (left_branch)
       left_branch->Grow(command, result);
      else {
       left_branch = new Tree(1);
       result = "sprouted left";
      }
    } else if (!strcmp(command, "water")) {
      if (right_branch)
       right_branch->Grow(command, result);
      else {
       right_branch = new Tree(1);
       result = "sprouted left";
      }
    } else {
      result = "unrecognized command for growing";
    }
  }

Here is the call graph for this function:


Member Data Documentation

Definition at line 116 of file tree.cxx.

Definition at line 115 of file tree.cxx.

int Tree::refcount [private]

Definition at line 110 of file tree.cxx.

Definition at line 115 of file tree.cxx.

Definition at line 118 of file tree.cxx.


The documentation for this class was generated from the following file: