I’m trying to understand whether it is possible / feasible to define recursive data structures using stdlib’s hash maps. For the most basic functionality, I would need a way to store maps and arrays, where the latter can be implemented as associative array using a map, as values.
However, the copy_other routine uses a sourced allocation, which means any data structure stored in a stdlib hash map will be copied in and later copied out this way:
For a recursive data structure this can be quite an issue, depending on the represented data, for example I found deep copy of a 2 MB JSON to be possible however quite expensive (TOML Fortran 0.3.0 - #3 by awvwgk).
I wonder whether there is a better way to create recursive data structures based on what we have available in stdlib.
My solution to this problem in rojff was to use move_alloc. In that way you can build up quite large recursive data structures without any copying. It gets really monotonous and tricky to get right if you do it all in one procedure, but there’s an example of it in the test suite. Check out the move_construct_with(out)_errorstest/construction_method_test.f90 · main · Brad Richardson / rojff · GitLab
I took a quick look, and I actually don’t see how one puts data into or fetches it from the stdlib hash map. I did see one type with a class(*) component, which would let you have recursive data structures (unless you mean the constructed data structure would have circular references, in which case I don’t think that’s possible).
Is there a tutorial, or user-guide for the stdlib hash map somewhere?
I used the stdlib hashmaps a few times and I was happy with its API and performances (in comparison to other fpmized hashmap projects). However, as it is still experimental, the API can still be changed and improved