BST_node* Binary_search_tree::search_helper(int x, BST_node* t) {
	if (t != nullptr){
		if (x > t->get_data()) {
			search_helper(x, t->get_right_child());
		} else if (x < t->get_data()) {
			search_helper(x, t->get_left_child());
		} else {
			return t;
		}
	} else{
		return t;
	}
}
Example #2
0
entity *search_helper(scope *scope, char *name, int classe) {
  debug(DEBUG_TDS, "\033[01;36msearch_helper\033[0m");
  if (scope == NULL) return NULL;

  entity *current_entity = scope->entities;

  while (current_entity != NULL) {
    if (strcmp(current_entity->name, name) == 0) {

      // IF FUNC_DECLARATION, we need a function
      if (   classe == FUNC_DECLARATION
          && current_entity->classe == classe)
            return current_entity;

      // IF VAR_DECLARATION, we need a var or a param
      if (   classe == VAR_DECLARATION
          && (   current_entity->classe == VAR_DECLARATION
              || current_entity->classe == PARAM ) )
            return current_entity;
    }


    current_entity = current_entity->brother;
  }

  return search_helper(scope->father, name, classe);
}
Example #3
0
const char *search_uncached( const char *target, time_t	*time ) {
	return search_helper( target, time, standard_search_var_get, NULL, 1 );
}
Example #4
0
const char *search_using_target_settings( TARGET *t, const char *target, time_t *time ) {
	return search_helper( target, time, search_using_target_settings_var_get, t, 0 );
}
BST_node* Binary_search_tree::search(int x) {
	return search_helper(x, root);
}