MCPcopy Create free account
hub / github.com/RedisGraph/RedisGraph / Map_KeyIdx

Function Map_KeyIdx

src/datatypes/map.c:42–63  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

40}
41
42static int Map_KeyIdx
43(
44 SIValue map,
45 SIValue key
46) {
47 ASSERT(SI_TYPE(map) & T_MAP);
48 ASSERT(SI_TYPE(key) & T_STRING);
49
50 Map m = map.map;
51 uint n = array_len(m);
52
53 // search for key in map
54 for(uint i = 0; i < n; i++) {
55 Pair pair = m[i];
56 if(strcmp(pair.key.stringval, key.stringval) == 0) {
57 return i;
58 }
59 }
60
61 // key not in map
62 return -1;
63}
64
65// create a new map
66SIValue Map_New

Callers 3

Map_RemoveFunction · 0.85
Map_GetFunction · 0.85
Map_ContainsFunction · 0.85

Calls 1

array_lenFunction · 0.85

Tested by

no test coverage detected