3 ms·
I don't think Node can contain a std::vector<Node>, since STL containers cannot have incomplete value types. But maybe I'm misunderstanding you? I think absl::
by psurge 7y ago
I don't think Node can contain a std::vector<Node>, since STL containers cannot have incomplete value types. But maybe I'm misunderstanding you?
I think absl::flat_hash_map<T, std::unique_ptr<Node>> would be worth considering in this application. Keys and values are stored inline, so the memory and creation costs should be comparable to std::vector - https://abseil.io/docs/cpp/guides/container#abslflat_hash_map-and-abslflat_hash_set https://abseil.io/docs/cpp/guides/container#abslflat_hash_ma...
- stabbles 7y agoNot all containers though, since C++17 std::vector, std::list and std::forward_list do support incomplete element types as long as the allocator meets certain requirements. So std::vector<Node> is definitely OK.
- saagarjha 7y ago> STL containers cannot have incomplete value types As of C++17, certain containers have minimal support for incomplete types.
- deleted 7y ago[deleted]
- codr7 7y agoTrue enough, my mistake :) Just getting rid of the hash buckets and shared_ptrs would be a giant leap in the right direction. Nice. I have no experience from absl, but I've sucessfully used sorted vectors to speed up these kinds of solutions on several occasions [0]. [0] https://github.com/codr7/cidk/blob/master/src/cidk/env.hpp https://github.com/codr7/cidk/blob/master/src/cidk/env.hpp