57书屋

图书馆的邀请与黑色的警告 (2/8)

bsp;{

    return key % size;

    }

    void insert(HashTable* ht, int key, int value) {

    int index = hash(key, ht->size);

    Node* newNode = (Node*)malloc(sizeof(Node));

    newNode->key = key;

    newNode->value = value;

    newNode->next = ht->table[index];

    ht->table[index] = newNode;

    }

    int find(HashTable* ht, int key) {

    int index = hash(key, ht->size);

    Node* current = ht->table[index];

    while(current != NULL) {

    if(current->key == key) {

    return current->value;

    }

    current = current->next;

    }

    return -1; \/\/ 未找到

    }

    void freeHashTable(HashTable* ht) {

    for(int i = 0; i size; i++) {

    Node* current = ht->table[i];

    while(current != NULL) {

    Node* temp = current;

    current = current->next;

    free(temp);

本章未完,请点击下一页继续阅读

『加入书签,方便阅读』
推荐小说:
星际御兽从古武开始 李恪:这皇子不当也罢 凡人修仙之玄骨传 高考落榜:我在恐怖游戏逆天改命 我在清末兑军火,从马匪到东北王 权势滔天:从拯救省府千金开始 我修无情道,系统却要我当恋爱脑 五岁萌娃会算卦,夜闯部队找爸爸 风灵月影,从我的世界开始 万人嫌大嫂重生后
相关推荐:
权势滔天:从拯救省府千金开始 华娱:从和台妹同居开始 重生2002:从网吧老板到全球首富 人在香江:我惊艳了一个时代 抽象系巨星