当前位置: 首页>>代码示例>>C++>>正文


C++ DArray_count函数代码示例

本文整理汇总了C++中DArray_count函数的典型用法代码示例。如果您正苦于以下问题:C++ DArray_count函数的具体用法?C++ DArray_count怎么用?C++ DArray_count使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了DArray_count函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Hashmap_destroy

void Hashmap_destroy(Hashmap *map)
{
	int i = 0;
	int j = 0;

	if(map) 
	{
		if(map->buckets) 
		{
			for(i = 0; i < DArray_count(map->buckets); i++) 
			{
				DArray *bucket = DArray_get(map->buckets, i);
				if(bucket) 
				{
					for(j = 0; j < DArray_count(bucket); j++) 
					{
						free(DArray_get(bucket,j));
					}
					DArray_destroy(bucket);
				}
			}
			DArray_destroy(map->buckets);
		}
		free(map);
	}
}
开发者ID:vajarkov,项目名称:C-TUTORIAL,代码行数:26,代码来源:hashmap.c

示例2: DArray_group_by

DArray DArray_group_by(DArray array, DArray_group_by_fn *group_by_fn)
{
  if (DArray_is_empty(array) || !group_by_fn) return NULL;

  DArray groups = DArray_create(sizeof(DArray), 10);
  DArray group;
  int idx;
  void *el;

  size_t count = (size_t) DArray_count(array);
  for (size_t i = 0; i < count; i++) {
    el = DArray_remove(array, i);
    if (!el) continue;
    idx = group_by_fn(el);
    if (idx == -1) continue;

    group = DArray_get(groups, idx);

    if (!group) {
      group = DArray_create(array->element_size, DArray_count(array) + 1);
      DArray_ensure_capacity(groups, idx + 1);
      DArray_set(groups, idx, group);
    }

    DArray_push(group, el);
  }

  return groups;
}
开发者ID:dash-project,项目名称:nasty-MPI,代码行数:29,代码来源:darray_algos.c

示例3: Hashmap_destroy

void Hashmap_destroy(Hashmap *map)
{
    int i = 0;
    int j = 0;

    if (map) {
        if (map->buckets) {
            for (i = 0; i < DArray_count(map->buckets); i++) {
                DArray *bucket = DArray_get(map->buckets, i);
                if (bucket) {
                    for (j = 0; j < DArray_count(bucket); j++) {
                        HashmapNode *node = DArray_get(bucket, j);
                        if (node != NULL) {
                            free(node->data);
                            map->free_key(node->key);
                        }
                    }

                    DArray_clear_destroy(bucket);

                    DArray_remove(map->buckets, i);
                }
            }
            DArray_clear_destroy(map->buckets);
        }

        free(map);
    }
}
开发者ID:imej,项目名称:c,代码行数:29,代码来源:hashmap.c

示例4: Hashmap_destroy

void 
Hashmap_destroy(Hashmap *map)
{
	int i = 0;
	int j = 0;

	if(!map){
		return;
	}

	if(!map->buckets){
		return;
	}

	for(i = 0; i < DArray_count(map->buckets); i++){
		//用DArray作桶,但桶里的每个元素也是DArray
		//用DArray代替链表避免hash碰撞
		//最后一层的DArray里放的才是HashmapNode
		DArray *bucket = DArray_get(map->buckets, i);
		if(!bucket){
			continue;	
		}

		for(j = 0; j < DArray_count(bucket); j++){
			free(DArray_get(bucket,j));
		}
		DArray_destroy(bucket);
	}
}
开发者ID:deyimsf,项目名称:journal,代码行数:29,代码来源:hashmap.c

示例5: Hashmap_destroy

void Hashmap_destroy(Hashmap *map, Hashmap_destroy_func destroy_f)
{
    int i = 0;
    int j = 0;

    if (map) {
        if (map->buckets) {
            for (i = 0; i < DArray_count(map->buckets); i++) {
                DArray *bucket = DArray_get(map->buckets, i);
                if (!bucket) continue;
                for (j = 0; j < DArray_count(bucket); j++) {
                    void *val = DArray_get(bucket, j);
                    HashmapNode *node = val;
                    bdestroy(node->key);
                    if (destroy_f != NULL) {
                        destroy_f(node->data);
                    }
                    free(val);
                }
                DArray_destroy(bucket);
            }
            DArray_destroy(map->buckets);
        }

        free(map);
    }
}
开发者ID:hunterbridges,项目名称:liblcthw,代码行数:27,代码来源:hashmap.c

示例6: DArray_get

NodeAddress *getFSFromServicePool() {
	NodeAddress *fsAddress = NULL;

	if (DArray_count(fsList) > 0) {
		fsAddress = DArray_get(fsList, fsPosition++);

		if (fsPosition == DArray_count(fsList))
			fsPosition = 0;
	}

	return fsAddress;
}
开发者ID:DebashisGanguly,项目名称:SFTP,代码行数:12,代码来源:NS.c

示例7: bfromcstr

char *test_getlines()
{
  bstring str = bfromcstr("one\ntwo\nthree\nfour\nfive\n");
  struct bstrList *file = bsplit(str, '\n');

  DArray *lines = getlines(file, 2, 4);

  bstring two = bfromcstr("two");
  bstring three = bfromcstr("three");
  bstring four = bfromcstr("four");

  mu_assert(DArray_count(lines) == 3, "Wrong number of lines.");
  mu_assert(bstrcmp((bstring)DArray_at(lines, 0), two) == 0, "First line is wrong.");
  mu_assert(bstrcmp((bstring)DArray_at(lines, 1), three) == 0, "Second line is wrong.");
  mu_assert(bstrcmp((bstring)DArray_at(lines, 2), four) == 0, "Third line is wrong.");

  bstrListDestroy(file);
  bdestroy(str);
  bdestroy(two);
  bdestroy(three);
  bdestroy(four);
  DArray_destroy(lines);

  return NULL;
}
开发者ID:txus,项目名称:terrorvm,代码行数:25,代码来源:file_utils_tests.c

示例8: VM_start

void VM_start(bstring binary, bstring filename)
{
  STATE = State_new();

  Runtime_init(state);

  VALUE lobby  = Lobby_new(state); // toplevel object
  state->lobby = lobby;
  state->binary = binary;

  BytecodeFile *file = BytecodeFile_new(state, filename);

  int fn_count = DArray_count(file->function_names);
  for(int j=0; j < fn_count; j++) {
    bstring fn_name = (bstring)DArray_at(file->function_names, j);
    Function *fn = (Function*)Hashmap_get(file->functions, fn_name);
    Hashmap_set(state->functions, fn_name, fn);
  }

  bstring main_fn = bfromcstr("0_main");
  CallFrame *top_frame = CallFrame_new(lobby, STATE_FN(main_fn), NULL);
  bdestroy(main_fn);
  top_frame->name = "main";

  Stack_push(FRAMES, top_frame);

  // now we're ready to bootstrap
  State_bootstrap(state);

  // and run the codes!
  VM_run(state);

  State_destroy(state);
}
开发者ID:txus,项目名称:terrorvm,代码行数:34,代码来源:vm.c

示例9: State_bootstrap

void
State_bootstrap(STATE)
{
  DArray *filenames = kernel_files(state);
  int count = DArray_count(filenames);

  // Expose toplevel constants
  expose_VM(state, state->lobby);

  int reenable_debugger = 0;

  // Disable debugger while loading kernel files
  if(Debug) {
    reenable_debugger = 1;
    Debug = 0;
  }

  // Load all files.
  for(int i=0; i < count; i++) {
    bstring filename = (bstring)DArray_at(filenames, i);
    bstring path = bfromcstr("kernel/");
    bconcat(path, filename);
    Primitive_require(state, String_new(state, bdata(path)), NULL, NULL);

    bdestroy(path);
    bdestroy(filename);
  }

  DArray_destroy(filenames);

  // Reenable debugger if needed
  if(reenable_debugger) Debug = 1;
}
开发者ID:txus,项目名称:terrorvm,代码行数:33,代码来源:bootstrap.c

示例10: CloseNodes_GetNodes

DArray *
CloseNodes_GetNodes(CloseNodes *close)
{
    assert(close != NULL && "NULL CloseNodes pointer");

    DArray *nodes = DArray_create(sizeof(Node *),
            DArray_max(close->close_nodes));
    check(nodes != NULL, "DArray_create failed");

    int i = 0;
    for (i = 0; i < DArray_count(close->close_nodes); i++)
    {
        struct CloseNode *close_node = DArray_get(close->close_nodes, i);
        check(close_node != NULL, "NULL CloseNodes entry");
        check(close_node->node != NULL, "NULL Node pointer in CloseNodes entry");

        int rc = DArray_push(nodes, close_node->node);
        check(rc == 0, "DArray_push failed");
    }

    return nodes;
error:
    DArray_destroy(nodes);
    return NULL;
}
开发者ID:polysome,项目名称:amok,代码行数:25,代码来源:close.c

示例11: Value_print_all

void Value_print_all(STATE, DArray* objs)
{
  for(int i=0; i < DArray_count(objs); i++) {
    Value_print(state, (VALUE)DArray_at(objs, i));
    printf("\n");
  }
}
开发者ID:txus,项目名称:terrorvm,代码行数:7,代码来源:vm.c

示例12: CloseNodes_Add

int 
CloseNodes_Add(CloseNodes *close, Node *node)
{
    assert(close != NULL && "NULL CloseNodes pointer");
    assert(node != NULL && "NULL Node pointer");

    Distance distance = Hash_Distance(&close->id, &node->id);
    int i = FindIndex(close->close_nodes, &distance);

    if (i < 0)
        return 0;

    struct CloseNode *close_node = malloc(sizeof(struct CloseNode));
    check_mem(close_node);

    close_node->node = node;
    close_node->distance = distance;

    if (DArray_count(close->close_nodes) < BUCKET_K)
        DArray_push(close->close_nodes, NULL);

    ShiftFrom(close->close_nodes, i);
    DArray_set(close->close_nodes, i, close_node);

    return 0;
error:
    return -1;
}
开发者ID:polysome,项目名称:amok,代码行数:28,代码来源:close.c

示例13: DArray_qsort

int DArray_qsort(DArray* array, DArray_compare cmp)
{
    DArray_check(array);
    qsort(array->contents, DArray_count(array), sizeof(void*), cmp);
    return 0;
error:
    return 1;
}
开发者ID:PaulForey,项目名称:learn-c-the-hard-way,代码行数:8,代码来源:darray_algos.c

示例14: get_parents

int* get_parents(const FeaturedSentence sent) {

    int *parents = (int*) malloc(sizeof (int) * (DArray_count(sent->words) + 1));
    check_mem(parents);

    parents[0] = -1;
    for (int i = 0; i < DArray_count(sent->words); i++) {
        Word w = (Word) DArray_get(sent->words, i);
        parents[i + 1] = w->parent;
    }

    return parents;

error:
    log_err("Error in allocating parents");
    exit(1);
}
开发者ID:hsensoy,项目名称:ai-parse,代码行数:17,代码来源:dependency.c

示例15: Vector_each_with_index

void Vector_each_with_index(VALUE vector, Vector_iter_idx iter)
{
  DArray *array = VAL2ARY(vector);
  int count = DArray_count(array);

  for(int i=0; i<count; i++) {
    iter((VALUE)DArray_at(array, i), i);
  }
}
开发者ID:txus,项目名称:terrorvm,代码行数:9,代码来源:vector.c


注:本文中的DArray_count函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。