typedef struct {
int hash[1000001];
} MyHashMap;
MyHashMap* myHashMapCreate() {
MyHashMap *ret = calloc (1, sizeof(MyHashMap));
memset(ret->hash, -1, sizeof(int) * 1000001);
// for (int i=0; i<1000001;i++)
// ret->hash[i]= -1;
return ret;
}
void myHashMapPut(MyHashMap* obj, int key, int value) {
obj->hash[key]= value;
}
int myHashMapGet(MyHashMap* obj, int key) {
return obj->hash[key];
}
void myHashMapRemove(MyHashMap* obj, int key) {
obj->hash[key] = -1;
}
void myHashMapFree(MyHashMap* obj) {
free (obj);
}
/**
* Your MyHashMap struct will be instantiated and called as such:
* MyHashMap* obj = myHashMapCreate();
* myHashMapPut(obj, key, value);
* int param_2 = myHashMapGet(obj, key);
* myHashMapRemove(obj, key);
* myHashMapFree(obj);
*/
沒有留言:
張貼留言