Answer the question
In order to leave comments, you need to log in
Container that does not change the order of elements when iterating
let there be a hash container
typedef .... container
/// ...
container<string,string> c;
where the elements are added in this order:c["Update"] = "...";
c["Connection"] = "...";
c["Sec"] = "...";
for ( auto it : c )
{
cout << c.first << ": " << c.second << endl;
}
Update: ... Connection: ... Sec: ...
Connection: ... Sec: ... Update: ...
Sec: ... Connection: ... Update: ...
Answer the question
In order to leave comments, you need to log in
Look at a similar question
. There are many answers in the answers, partially overlapping with those given here.
Well, you came up with the name. Before entering, I thought some kind of container changes the order during iteration :)
Regarding the question: “Do you want checkers or go?” Do you want to have quick access and keep order? but that won't work. Choose either this or that. If you do not have large volumes, then you can store a vector with the necessary strings and std::hash / map with strings, the values of which will be indices in the vector.
If I understand correctly, you need a FIFO queue. I may be wrong, but look at std::queue (if the elements are extracted one by one) or std::vector, std::list (as far as I remember, the order does not change in them). Already in the queue, you can push your structure with two fields.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question