Associative array

bachmeier no at spam.net
Fri Oct 13 14:34:04 UTC 2023


On Friday, 13 October 2023 at 11:32:29 UTC, Imperatorn wrote:
> Hello there.
>
> I'm wondering if anyone would be opposed to us/me making 
> associative array having resize/reserve public?
>
> Currently there exists private members in druntime etc for this 
> but they are not exposed.
>
> Basically I would like to be able to reserve n buckets before 
> populating.
>
> For reference, see std::unordered_map, which is kvp, which has 
> rehashing etc:
>
> ```cpp
>   template<typename _Key, typename _Tp,
> 	   typename _Hash = hash<_Key>,
> 	   typename _Pred = equal_to<_Key>,
> 	   typename _Alloc = allocator<std::pair<const _Key, _Tp>>>
>     class unordered_map
>     {
>       typedef __umap_hashtable<_Key, _Tp, _Hash, _Pred, _Alloc> 
>  _Hashtable;
>       _Hashtable _M_h;
> ```
>
> https://github.com/gcc-mirror/gcc/blob/master/libstdc%2B%2B-v3/include/bits/unordered_map.h
>
> https://github.com/gcc-mirror/gcc/blob/master/libstdc%2B%2B-v3/include/bits/hashtable.h

It's something I've wanted. There was a discussion this summer: 
https://forum.dlang.org/post/u8fp23$2462$1@digitalmars.com


More information about the Digitalmars-d mailing list