1

Topic: static_map/static_unordered_map?

Greetings! Whether saw who-thread subject implementation? It is necessary that did not use a heap, but only a stack. A key and value - fundamental types. Thanks.

2

Re: static_map/static_unordered_map?

Hello, niXman, you wrote: whether X> saw who-thread subject implementation? X> it is necessary that did not use a heap, but only a stack. A key and value - fundamental types. Saw to use a heap with a minimum : boost:: flat_map I Think, it is possible it  and slightly to change its source codes, interrupting in its implementation boost:: container:: vector on boost:: container:: small_vector or boost:: container:: static_vector

3

Re: static_map/static_unordered_map?

Hello, Alexander G, you wrote: AG> I Think, it is possible it  and slightly to change its source codes, interrupting in its implementation boost:: container:: vector on boost:: container:: small_vector or boost:: container:: static_vector well... Abruptly... And something ready?

4

Re: static_map/static_unordered_map?

Hello, niXman, you wrote: X> it is necessary that did not use a heap, but only a stack. A key and value - fundamental types. Intrusiv' containers?

5

Re: static_map/static_unordered_map?

Hello, EreTIk, you wrote: ETI> Intrusiv' containers? Like as a variant, but it is necessary to think what to change for usage this...

6

Re: static_map/static_unordered_map?

Hello, niXman, you wrote: X> well... Abruptly... And something ready? Well there is also a ready variant, even without , but literary trash will be more. Old kind lower_bound/upper_bound and the sorted array: #include <iostream> #include <array> #include <algorithm> struct CompareFirst {template <typename K, typename V> bool operator () (const std:: pair <K, V>& l, const std:: pair <K, V>& r) const {return (l.first <r.first);} template <typename K, typename V> bool operator () (const std:: pair <K, V>& l, const K& r) const {return (l.first <r);} template <typename K, typename V> bool operator () (const K& l, const std:: pair <K, V>& r) const {return (l <r.first);} }; auto MakeValues () {using KV = std:: pair <int, int>; KV data [] = {{1, 5}, {4, 7}, {3, 6},}; const std:: size_t size = sizeof (data)/sizeof (data [0]); std:: array <KV, size> result; std:: copy_n (data, size, result.begin ()); std:: sort (result.begin (), result.end (), CompareFirst {}); return result;} auto Values = MakeValues (); int main () {std:: cout <<std:: lower_bound (Values.begin (), Values.end (), 3, CompareFirst {})-> second;}

7

Re: static_map/static_unordered_map?

Hello, niXman, you wrote: X> greetings! Whether X> saw who-thread subject implementation? X> it is necessary that did not use a heap, but only a stack. A key and value - fundamental types. X> thanks. What use-case? The wrapper over a normal vector/file does not solve a problem with sorting?

8

Re: static_map/static_unordered_map?

Hello, niXman, you wrote: X> Hello, Alexander G, you wrote: AG>> I Think, it is possible it  and slightly to change its source codes, interrupting in its implementation boost:: container:: vector on boost:: container:: small_vector or boost:: container:: static_vector X> well... Abruptly... And something ready? It is possible to use ready  https://howardhinnant.github.io/stack_alloc.html the Example: #include <boost/container/flat_map.hpp> #include <short_alloc.h> template <typename Key, typename T, typename Comparer = std:: less <Key>, size_t Size = 1024> class stack_flat_map: private short_alloc <std:: pair <Key, T>, Size*sizeof (std:: pair <Key, T>)>:: arena_type, public boost:: container:: flat_map <Key, T, Comparer, short_alloc <std:: pair <Key, T>, Size*sizeof (std:: pair <Key, T>)>> {typedef short_alloc <std:: pair <Key, T>, Size*sizeof (std:: pair <Key, T>)> t_alolocator; typedef typename t_alolocator:: arena_type t_arena; typedef boost:: : container:: flat_map <Key, T, Comparer, t_alolocator> t_base; public: stack_flat_map (): t_arena (), t_base (static_cast<t_arena&> (*this)) {reserve (Size);}}; _CrtMemState st1, st2, st_diff; _CrtMemCheckpoint (&st1); stack_flat_map <int, int> map; for (int i=0; i <1024; ++ i) map [i] = i*10; _CrtMemCheckpoint (&st2);:: _CrtMemDifference (&st_diff, &st1, &st2);:: _CrtMemDumpStatistics (&st_diff); To a heap switches only after  arenas on a stack...

9

Re: static_map/static_unordered_map?

Hello, Alexander G, you wrote: AG> Well there is also a ready variant, even without , but literary trash will be more. Thanks, but already started to "dig" in other side... Namely: sorting of keys in a kompajl-time.  I will create a topic. This while is frozen.  thanks!

10

Re: static_map/static_unordered_map?

Hello, niXman, you wrote: whether X> saw who-thread subject implementation? X> it is necessary that did not use a heap, but only a stack. A key and value - fundamental types. If a line-> value that gperf