So, I'm trying to implement a Trie tree for sorting lexicographically my code. But because it's for a competition, I'm trying to cut down on time. Because of that, instead of a std::vector
, I decided to use std::list
, so I don't have to deal with all the reallocation. But I ran into a problem, namely using pointers for storing where my element is (because I don't want to have linear time instead of constant time when restoring my elements).
My idea is to make a list of lists, where each sub-list contains pairs of int
's and "pointers". So:
list<list<pair<int, list<void>::iterator>> trie;
As you can see, I tried to use iterators as "pointers", but then I run into a recursive type. I've replaced it with void
as a placeholder, but normally it would look like this:
list<list<pair<int, list<list<list<pair<int, list<(......)>::iterator>>>::iterator>>
Doesn't sound too good. As my "pointer" I also tried an actual pointer, but from what I saw, making an iterator from a pointer is as good as searching the list for an element with that pointer, which brings me back to my problem. Is there a way to get rid of the recursive type? Or, even better, is there some better "pointer" which would work for me?