Go to the documentation of this file.
29 size_t initial_capacity) {
34 static_cast<void**
>(
gpr_malloc(
sizeof(
void*) * initial_capacity));
37 map->capacity = initial_capacity;
98 template <
bool strict_find>
101 size_t max_idx =
map->count;
108 if (!strict_find && max_idx == 0)
return nullptr;
110 while (min_idx < max_idx) {
112 mid_idx = min_idx + ((max_idx - min_idx) / 2);
113 mid_key =
keys[mid_idx];
116 min_idx = mid_idx + 1;
117 }
else if (mid_key >
key) {
130 void** pvalue = find<true>(
map,
key);
138 if (
map->free ==
map->count) {
139 map->free =
map->count = 0;
146 void** pvalue = find<false>(
map,
key);
147 return pvalue !=
nullptr ? *pvalue :
nullptr;
151 return map->count -
map->free;
155 if (
map->count ==
map->free) {
158 if (
map->free != 0) {
163 return map->values[(
static_cast<size_t>(rand())) %
map->count];
172 for (
i = 0;
i <
map->count;
i++) {
173 if (
map->values[
i]) {
174 f(user_data,
map->keys[
i],
map->values[
i]);
static size_t compact(uint32_t *keys, void **values, size_t count)
static void ** find(grpc_chttp2_stream_map *map, uint32_t key)
#define GPR_DEBUG_ASSERT(x)
GPRAPI void gpr_free(void *ptr)
GPRAPI void * gpr_malloc(size_t size)
void grpc_chttp2_stream_map_add(grpc_chttp2_stream_map *map, uint32_t key, void *value)
GPRAPI void * gpr_realloc(void *p, size_t size)
void * grpc_chttp2_stream_map_find(grpc_chttp2_stream_map *map, uint32_t key)
void grpc_chttp2_stream_map_for_each(grpc_chttp2_stream_map *map, void(*f)(void *user_data, uint32_t key, void *value), void *user_data)
void * grpc_chttp2_stream_map_delete(grpc_chttp2_stream_map *map, uint32_t key)
void * grpc_chttp2_stream_map_rand(grpc_chttp2_stream_map *map)
size_t grpc_chttp2_stream_map_size(grpc_chttp2_stream_map *map)
void grpc_chttp2_stream_map_destroy(grpc_chttp2_stream_map *map)
void grpc_chttp2_stream_map_init(grpc_chttp2_stream_map *map, size_t initial_capacity)
std::array< int64_t, Size > values
grpc
Author(s):
autogenerated on Fri May 16 2025 03:00:20