Nested HashMap
in
Programming Questions
•
2 years ago
hi,
i want to program a markov model. for now, it should have an oder of 3 and work with integers (maybe later also chars). I also want the model to be able to train itself automatically, by "feeding in" sequences of 3 integers.
it seems to me at the moment a good way would be to work with hashmaps that are nested into each other, basically like this:
1st level HM start
|
| key1
| 2nd level HM start
| |
| | key1
| | 3rd level HM start
| | |
| | | key 1, value 1
| | | key 2, value 2
| | | key 3, value 3
| | | ...
| | |
| | 3rd level HM end
| |
| | key2
| | 3rd level HM start
| | | ...
| | 3rd level HM end
| |
| 2nd level HM end
|
| key2
| 2nd level HM start
| | ...
| 2nd level HM end
|
| key3
| 2nd level HM start
| | ...
| 2nd level HM end
|
1st level HM end
i thought it would be a good solution to write an own "Entry" class that extends the HashMap class; so that an entry on the 1st and 2nd level always contains another hashmap, and an entry on the 3rd level contains elements and their respective stochastic probability to appear after the elements of the 1st and 2nd level.
if there are any recommendations, examples, links relating to this or to nestig objects, i would be happy to hear them.
regards, florian.
1