Example #1
0
void test_set_operations(){
	set_t *even1 = new_set(10);
	set_t *even2 = new_set(10);
	set_t *odd  = new_set(10);
	
	int i;
	for (i=0; i < 10; i++){
		set_put(even1, 2*i);
		set_put(even2, 2*i);
		set_put(odd, 2*i+1);
	}
	
	set_union(even1, odd);
	assert(set_size(even1) == 20);
	
	set_difference(even2, odd);
	assert(set_size(even2) == 10);
	
	set_intersection(even2, odd);
	assert(set_size(even2) == 0);
	
	set_print(even1); printf("\n");
	set_optimize(even1);
	set_print(even1); printf("\n");
	
	set_print(even2); printf("\n");
	set_print(odd); printf("\n");
	
	delete_set(even1);
	delete_set(even2);
	delete_set(odd);
}
Example #2
0
/*
 * db_col_optimize() - This function makes the set is in its optimal order
 *    for performance(sort overhead) reason.
 * return : error status
 * col(in): collection
 */
int
db_col_optimize (DB_COLLECTION * col)
{
  int error = NO_ERROR;

  CHECK_CONNECT_ERROR ();
  CHECK_1ARG_ERROR (col);

  error = set_optimize (col);

  return error;
}
Example #3
0
void test_removing(){
	set_t *set = new_set(0);
	
	int i;
	for (i=0; i < 1000; i++){ set_put(set, i); }
	assert(set_size(set) == 1000);
	
	set_optimize(set);
	
	for (i=0; i < 1000; i += 2){ set_remove(set, i); }
	assert(set_size(set) == 500);
	
	for (i=0; i < 1000; i += 2){ set_put(set, i); }
	assert(set_size(set) == 1000);
	
	delete_set(set);
}
Example #4
0
File: fcc.c Project: 8l/FUZIX
int main(int argc, const char *argv[]) {
  const char *p;
  char *t;
  int i;
  int ret;
  char buf[128];
  
  for(i = 1; i < argc; i++) {
    p = argv[i];
    if (*p != '-')
      add_source(p);
    else {
      switch(p[1]) {
        case 'V':
          verbose = 1;
          break;
        /* What are we doing */
        case 'c':
          mode = MODE_OBJ;
          break;
        case 'E':
          mode = MODE_CPP;
          break;
        case 'S':
          mode = MODE_ASM;
          break;
        case 'v':
          printf("fcc: front end to sdcc\n");
          add_argument("sdcc");
          add_argument("-v");
          do_command();
          exit(0);
        case 'D':
          add_macro(p);
          break;
        case 'l':
          add_library(p+2);
          break;
        case 'L':
          if (p[2] == 0)
            add_library_path(argv[++i]);
          else
            add_library_path(p+2);
          break;
        case 'I':
          if (p[2] == 0)
            add_include_path(argv[++i]);
          else
            add_include_path(p+2);
          break;
        case 'o':
          if (p[2] == 0)
            set_target(argv[++i]);
          else
            set_target(p + 2);
          break;
        case 'O':
          set_optimize(p + 2);
          break;
        case 'm':
          if (p[2] == 0)
            set_cpu(argv[++i]);
          else
            set_cpu(p + 2);
          break;
        case 'M':
          if (p[2] == 0)
            set_map(argv[++i]);
          else
            set_map(p + 2);
          break;
        case 't':
          if (p[2] == 0)
            set_platform(argv[++i]);
          else
            set_platform(p + 2);
          break;
        case 'g':
          debug = 1;
          break;
        default:
          if (strcmp(p, "-Werror") == 0)
            werror = 1;
          else if (strcmp(p, "-funsigned-char") == 0)
            unschar = 1;
          else if (strcmp(p, "--pedantic") == 0)
            pedantic = 1;
          else if (strcmp(p, "--nostdio") == 0)
            nostdio = 1;
          else {
            fprintf(stderr, "fcc: Unknown option '%s'.\n", p);
            exit(1);
          }
      }
    }
  }
  add_include_path(FCC_DIR "/include/");
  add_library_path(FCC_DIR "/lib/");
  snprintf(buf, sizeof(buf), "c%s", platform);
  add_library(buf);

  if (mode == MODE_OBJ) {
    while (srchead) {
      build_command();
      ret = do_command();
      if (ret)
        break;
      if (mode == MODE_OBJ && target) {
        char *orel = filebasename(rebuildname("", srchead->p, "rel"));
        if (rename(orel, target) == -1) {
          fprintf(stderr, "Unable to rename %s to %s.\n", orel, target);
          perror(srchead->p);
          exit(1);
        }
      }
      srchead = srchead->next;
      argp = 0;
    }
  } else {
      build_command();
      ret = do_command();
  }  
  if (mode != MODE_LINK || ret)
    exit(ret);
  argp = 0;
  add_argument("makebin");
  add_argument("-p");
  add_argument("-s");
  add_argument("65535");
  add_argument(target);
  add_argument(t = rebuildname("", target, "bin"));
  ret = do_command();
  if (ret)
    exit(ret);
  argp = 0;
  add_argument(FCC_DIR "/bin/binman");
  snprintf(buf, sizeof(buf), "%x", progbase);
  add_argument(buf);
  add_argument(t);
  add_argument(rebuildname("", target, "map"));
  add_argument(target);
  ret = do_command();
  exit(ret);
}