コード例 #1
0
ファイル: Hashmap_a.c プロジェクト: fill1890/lcthwlib
int Hashmap_set(Hashmap* map, void* key, void* data) {
    uint32_t hash = 0;
    DArray* bucket = Hashmap_find_bucket(map, key, 1, &hash);
    check(bucket, "Can't create bucket.");

    HashmapNode* node = Hashmap_node_create(hash, key, data);
    check_mem(node);

    DArray_push(bucket, node);

    return 0;

error:
    return 01;
}
コード例 #2
0
ファイル: hashmap.c プロジェクト: BMJHayward/liblcthw
int Hashmap_set(Hashmap *map, void *key, void *data)//finds a bucket create node add node to bucket
{
    uint32_t hash = 0;
    DArray *bucket = Hashmap_find_bucket(map, key, 1, &hash);//int 1 tells fn to create bucket if none found
    check(bucket, "Error can't create bucket.");

    HashmapNode *node = Hashmap_node_create(hash, key, data);
    check_mem(node);

    DArray_push(bucket, node);

    return 0;

error:
    return -1;
}