MCPcopy Create free account
hub / github.com/codemistic/Data-Structures-and-Algorithms / put

Method put

Hashtable/design-hashmap.cpp:8–17  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6 vector<pair<int,int>> bucket[100]; //bucket is an array whose each element is a vector of pair
7
8 void put(int key, int value) {
9 int index = key%100;
10 for(int i=0 ; i<bucket[index].size(); i++){
11 if(bucket[index][i].first==key){
12 bucket[index][i].second=value;
13 return;
14 }
15 }
16 bucket[index].push_back({key,value});
17 }
18
19 int get(int key) {
20 int index = key%100;

Callers 3

traversalMethod · 0.45
mainMethod · 0.45
longestStrChainMethod · 0.45

Calls 2

push_backMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected