コード例 #1
0
ファイル: tree.c プロジェクト: meiao/cte
/*
 * Creates a node and associates the given node as its parent and the given symbol as its own.
 */
Tree_node* create_node_child(Tree_node* parent, char symbol, int type) {
  Tree_node* child = new_Tree_node();
  child->symbol = symbol;
  child->parent = parent;

  // allocate memory for the data structure corresponding to the given type.
  if (type == BIC) {
    child->bic_data = (Bic_data*) malloc(sizeof(Bic_data));
  } else if (type == PROB){
    child->prob_data = (Prob_data*) malloc(sizeof(Prob_data));
  }

  return child;
}
コード例 #2
0
ファイル: tree.c プロジェクト: arnaldomandel/cte
/*
 * Creates a node and associates the given node as its parent and the given symbol as its own.
 */
Tree_node create_child_node(Tree_node parent, char symbol, int type) {
  Tree_node child = new_Tree_node();
  child->type = type;
  child->symbol = symbol;
  child->parent = parent;
  child->depth = parent ? parent->depth + 1 : 0;

  /* 
   * // allocate memory for the data structure corresponding to the given type.
   * if (type == BIC) {
   *     MEM(,child->b, (Bic_data) calloc(1, sizeof(struct bic_data)));
   * } else if (type == PROB){
   *     MEM(,child->p, (Prob_data) calloc(1, sizeof(struct prob_data)));
   * }
   */
  
  return child;
}