コード例 #1
0
ファイル: tree.c プロジェクト: lchish/cosc
/**
 * Inserts a new key into the tree.
 * @param t tree to put key into.
 * @param s key to insert.
 * @return tree with key inserted.
 */
tree tree_insert(tree t,char *s)
{
  if(t == NULL){/*empty tree*/
    t = emalloc(sizeof *t);
    t->key = emalloc(strlen(s) * sizeof s[0] + 1);
    t->colour = RED;
    strcpy(t->key,s);
  }else if(strcmp(t->key,s)==0){/*do nothing*/
  }else if(strcmp(t->key,s) < 0){/*s > b-key */
    t->right = tree_insert(t->right,s);
  }
  else if(strcmp(t->key,s) > 0){/*s < b-key*/
    t->left = tree_insert(t->left,s);
  }
  if(tree_type == RBT){
    t = tree_fix(t);
  }
  return t;
}
コード例 #2
0
ファイル: vfudir.cpp プロジェクト: svilendobrev/svd_bin
void tree_rebuild()
{
#ifdef _TARGET_GO32_
// we do need only files sizes -- so the other stuff under dos is unneeded :)
_djstat_flags = _STAT_INODE | _STAT_EXEC_EXT | _STAT_EXEC_MAGIC |
                _STAT_EXEC_MAGIC | _STAT_DIRSIZE | _STAT_ROOT_TIME |
                _STAT_WRITEBIT;
// _djstat_flags = 0;
#endif
  dir_tree.undef();
  size_cache.undef();
  say1( "Rebuilding tree..." );
  
  __tree_rebuild_process( "/" );
  
  tree_fix();
#ifdef _TARGET_GO32_
 _djstat_flags = 0;
#endif

  dir_tree_changed = 1;
  tree_save();
};