Lines Matching refs:map

18 /* We implement the map as two parallel arrays.
25 * number of items in the map.
42 AIntMap* map;
44 ANEW0(map);
45 map->size = 0;
46 map->capacity = 4;
47 map->keys = map->keys0;
48 map->values = map->values0;
50 return map;
54 aintMap_free( AIntMap* map )
56 if (map) {
57 if (map->keys != map->keys0)
58 AFREE(map->keys);
59 if (map->values != map->values0)
60 AFREE(map->values);
62 map->size = 0;
63 map->capacity = 0;
64 AFREE(map);
69 aintMap_getCount( AIntMap* map )
71 return map->size;
75 aintMap_get( AIntMap* map, int key )
77 return aintMap_getWithDefault(map, key, NULL);
81 aintMap_getWithDefault( AIntMap* map, int key, void* def )
83 int limit = map->size + 1;
85 int* keys = map->keys;
90 return map->values[index];
97 aintMap_grow( AIntMap* map )
99 int oldCapacity = map->capacity;
101 void* keys = map->keys;
102 void* values = map->values;
104 if (keys == map->keys0)
107 if (values == map->values0)
118 map->keys = keys;
119 map->values = values;
120 map->capacity = newCapacity;
125 aintMap_set( AIntMap* map, int key, void* value )
132 keys = map->keys;
133 limit = map->size;
142 if (map->size >= map->capacity)
143 aintMap_grow(map);
145 map->keys[limit] = key;
146 map->values[limit] = value;
147 map->size ++;
151 result = map->values[index];
152 map->values[index] = value;
158 aintMap_del( AIntMap* map, int key )
164 keys = map->keys;
165 limit = map->size;
175 result = map->values[index];
179 map->keys[index] = map->keys[limit];
180 map->values[index] = map->values[limit];
182 map->size -= 1;
190 aintMapIterator_init( AIntMapIterator* iter, AIntMap* map )
195 iter->magic[2] = map;
202 AIntMap* map;
208 map = iter->magic[2];
210 if (index >= map->size) {
215 iter->key = map->keys[index];
216 iter->value = map->values[index];