4 ms·
Correct. While vectors are comparable, C++ also guarantees a lot about the rest of the containers. E.g. unordered associative containers never expire pointers
by Const-me 9y ago
Correct.
While vectors are comparable, C++ also guarantees a lot about the rest of the containers. E.g. unordered associative containers never expire pointers to keys or values. Linked lists never expire pointers nor iterators.
In C++ I can create an efficient LRU cache in a dozen lines of code, combining list<const tKey* > with unordered_map<tKey, struct{tValue, list<const tKey* >::iterator}> (this implies tKey is not an int, otherwise list<tKey> is more efficient). Rust’s built-in LinkedHashMap had to reimplement a linked list instead.
- oconnor663 9y agoThanks for the example -- it was hard for me to picture what was going on before. I wonder if the unstable "Placer" APIs will make the standard LinkedList more capable of this sort of thing, but I'm not really familiar with them. Still, I suspect it'll always require `unsafe`.