1 #ifndef DS_MAP_H 2 #define DS_MAP_H 3 4 #include "../common.h" 5 #include "ds_htable.h" 6 #include "../php/objects/php_pair.h" 7 8 typedef struct _ds_map_t { 9 ds_htable_t *table; 10 } ds_map_t; 11 12 #define DS_MAP_SIZE(m) ((m)->table->size) 13 #define DS_MAP_IS_EMPTY(m) (DS_MAP_SIZE(m) == 0) 14 15 ds_map_t *ds_map(); 16 ds_map_t *ds_map_clone(ds_map_t *map); 17 18 void ds_map_clear(ds_map_t *map); 19 void ds_map_free(ds_map_t *map); 20 21 void ds_map_reverse(ds_map_t *map); 22 ds_map_t *ds_map_reversed(ds_map_t *map); 23 24 zval *ds_map_get(ds_map_t *map, zval *key, zval *def); 25 void ds_map_put(ds_map_t *map, zval *key, zval *value); 26 void ds_map_remove(ds_map_t *map, zval *key, zval *def, zval *return_value); 27 28 bool ds_map_has_key(ds_map_t *map, zval *key); 29 bool ds_map_has_value(ds_map_t *map, zval *value); 30 31 bool ds_map_has_keys(ds_map_t *map, VA_PARAMS); 32 bool ds_map_has_values(ds_map_t *map, VA_PARAMS); 33 34 35 void ds_map_to_array(ds_map_t *map, zval *return_value); 36 void ds_map_put_all(ds_map_t *map, zval *values); 37 38 ds_map_t *ds_map_slice(ds_map_t *map, zend_long index, zend_long length); 39 40 zval *ds_map_values(ds_map_t *map); 41 42 ds_map_t *ds_map_map(ds_map_t *map, FCI_PARAMS); 43 ds_map_t *ds_map_filter(ds_map_t *map); 44 ds_map_t *ds_map_filter_callback(ds_map_t *map, FCI_PARAMS); 45 46 void ds_map_allocate(ds_map_t *map, zend_long capacity); 47 zend_long ds_map_capacity(ds_map_t *map); 48 49 void ds_map_sort_by_value_callback(ds_map_t *map); 50 void ds_map_sort_by_value(ds_map_t *map); 51 void ds_map_sort_by_key_callback(ds_map_t *map); 52 void ds_map_sort_by_key(ds_map_t *map); 53 54 ds_map_t *ds_map_sorted_by_value_callback(ds_map_t *map); 55 ds_map_t *ds_map_sorted_by_value(ds_map_t *map); 56 ds_map_t *ds_map_sorted_by_key_callback(ds_map_t *map); 57 ds_map_t *ds_map_sorted_by_key(ds_map_t *map); 58 59 ds_map_t *ds_map_merge(ds_map_t *map, zval *values); 60 ds_map_t *ds_map_xor(ds_map_t *map, ds_map_t *other); 61 ds_map_t *ds_map_diff(ds_map_t *map, ds_map_t *other); 62 ds_map_t *ds_map_intersect(ds_map_t *map, ds_map_t *other); 63 ds_map_t *ds_map_union(ds_map_t *map, ds_map_t *other); 64 65 php_ds_pair_t *ds_map_first(ds_map_t *map); 66 php_ds_pair_t *ds_map_last(ds_map_t *map); 67 php_ds_pair_t *ds_map_skip(ds_map_t *map, zend_long position); 68 69 void ds_map_sum(ds_map_t *map, zval *return_value); 70 void ds_map_reduce(ds_map_t *map, FCI_PARAMS, zval *initial, zval *return_value); 71 void ds_map_apply(ds_map_t *map, FCI_PARAMS); 72 73 74 #endif 75