52 0, 2, 4, 6, 8, 10, 12,
53 17, 23, 29, 37, 47, 59, 73,
54 97, 127, 167, 223, 293, 389, 521, 691, 919, 1223, 1627, 2161,
55 3229, 4831, 7243, 10861, 16273, 24407, 36607, 54907,
66 return (x + x / 2) | 1;
115 size_t old_alloc = map->
alloc;
120 map->
alloc = new_alloc;
123 map->
table = new_table;
124 for (
size_t i = 0; i < old_alloc; i++) {
144 if (compare_only_ptrs) {
145 if (MP_OBJ_IS_QSTR(index)) {
153 compare_only_ptrs =
false;
164 if (elem->key == index || (!compare_only_ptrs &&
mp_obj_equal(elem->key, index))) {
169 memmove(elem, elem + 1, (top - elem - 1) *
sizeof(*elem));
189 if (!MP_OBJ_IS_QSTR(index)) {
197 if (map->
alloc == 0) {
207 if (MP_OBJ_IS_QSTR(index)) {
213 size_t pos = hash % map->
alloc;
214 size_t start_pos = pos;
222 if (avail_slot ==
NULL) {
225 avail_slot->
key = index;
227 if (!MP_OBJ_IS_QSTR(index)) {
236 if (avail_slot ==
NULL) {
239 }
else if (slot->
key == index || (!compare_only_ptrs &&
mp_obj_equal(slot->
key, index))) {
257 pos = (pos + 1) % map->
alloc;
259 if (pos == start_pos) {
262 if (avail_slot !=
NULL) {
265 avail_slot->
key = index;
267 if (!MP_OBJ_IS_QSTR(index)) {
275 start_pos = pos = hash % map->
alloc;
287 #if MICROPY_PY_BUILTINS_SET 296 size_t old_alloc =
set->alloc;
301 for (
size_t i = 0; i < old_alloc; i++) {
313 if (set->alloc == 0) {
321 size_t pos = hash %
set->alloc;
322 size_t start_pos = pos;
329 if (avail_slot ==
NULL) {
330 avail_slot = &
set->table[pos];
340 if (avail_slot ==
NULL) {
341 avail_slot = &
set->table[pos];
348 if (set->table[(pos + 1) % set->alloc] ==
MP_OBJ_NULL) {
359 pos = (pos + 1) % set->alloc;
361 if (pos == start_pos) {
364 if (avail_slot !=
NULL) {
373 start_pos = pos = hash %
set->alloc;
383 for (
size_t pos = 0; pos <
set->alloc; pos++) {
384 if (MP_SET_SLOT_IS_FILLED(
set, pos)) {
388 if (set->table[(pos + 1) % set->alloc] ==
MP_OBJ_NULL) {
407 #endif // MICROPY_PY_BUILTINS_SET 409 #if defined(DEBUG_PRINT) && DEBUG_PRINT 411 for (
size_t i = 0; i < map->
alloc; i++) {
mp_obj_t mp_unary_op(mp_unary_op_t op, mp_obj_t arg)
STATIC void mp_map_rehash(mp_map_t *map)
#define mp_seq_clear(start, len, alloc_len, item_sz)
#define MP_OBJ_IS_TYPE(o, t)
#define m_del(type, ptr, num)
void mp_map_init_fixed_table(mp_map_t *map, size_t n, const mp_obj_t *table)
void mp_map_init(mp_map_t *map, size_t n)
#define MP_OBJ_QSTR_VALUE(o)
void mp_obj_print(mp_obj_t o_in, mp_print_kind_t kind)
bool mp_obj_equal(mp_obj_t o1, mp_obj_t o2)
STATIC const uint16_t hash_allocation_sizes[]
void mp_map_clear(mp_map_t *map)
const mp_map_t mp_const_empty_map
#define MP_OBJ_SMALL_INT_VALUE(o)
mp_map_elem_t * mp_map_lookup(mp_map_t *map, mp_obj_t index, mp_map_lookup_kind_t lookup_kind)
void mp_set_init(mp_set_t *set, size_t n)
void mp_map_deinit(mp_map_t *map)
mp_uint_t qstr_hash(qstr q)
mp_obj_t mp_set_remove_first(mp_set_t *set)
void * memmove(void *dst, const void *src, size_t n)
mp_obj_t mp_set_lookup(mp_set_t *set, mp_obj_t index, mp_map_lookup_kind_t lookup_kind)
const mp_obj_type_t mp_type_str
STATIC size_t get_hash_alloc_greater_or_equal_to(size_t x)
void mp_map_dump(mp_map_t *map)
#define m_new0(type, num)
#define m_renew(type, ptr, old_num, new_num)
enum _mp_map_lookup_kind_t mp_map_lookup_kind_t
void mp_set_clear(mp_set_t *set)
size_t all_keys_are_qstrs