Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8187081
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T02:26:38+00:00 2026-06-07T02:26:38+00:00

For both std::map and std::tr1::unordered_map , I see from the standard that: References to

  • 0

For both std::map and std::tr1::unordered_map, I see from the standard that:

References to elements in the unordered_map container remain valid in
all cases, even after a rehash.

How are they doing that (implementation-wise)? Are they maintaining all the entries as a kind of linked list and then the hash-table just stores pointers to the elements?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T02:26:39+00:00Added an answer on June 7, 2026 at 2:26 am

    Yes, linked lists are involved, although not quite in the way you suggest.

    The 2011 standard says (23.2.5 para 8), “The elements of an unordered associative container are organized into buckets. Keys with the same hash code appear in the same bucket.”

    Within each bucket, the elements are in a linked list (a separate list for each bucket, not one big list for the whole container). When the container is rehashed, the elements will be assigned to new buckets, but the pointers to each element remain valid. The linked list in each new bucket is assembled from pointers to the existing elements that end up in that bucket.

    Iterators are invalidated by a rehash, since an iterator needs to hold pointers to both the element and its bucket (so it can be stepped from the last element of one bucket to the first element of the next). The element pointer remains valid, so existing pointers and references to an element are still valid, but the bucket pointer is invalidated by a rehash, so the iterator isn’t usable.

    (This is also why unordered containers only support forward iterators, instead of the bidirectional iterators supported by the ordered associative containers. The elements of each bucket are in a singly linked list, so you can’t step backwards through them.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If I understand it correctly, both std::map and std::unordered_map store keys explicitely (store pairs
Since both std::priority_queue and std::set (and std::multiset ) are data containers that store elements
std::map find/end both provides const_iterator and iterator, e.g. iterator end (); const_iterator end ()
After writing: std::pair<int, int> x; Am I guaranteed that x.first and x.second are both
The new C++11 standard has unordered containers. In particular, the std::unordered_map<Key, Value> stores a
I'm trying to export classes from a DLL that contain objects such as std::vectors
I'm using MinGW 4.5.2 and I'd like to use unordered_map from the tr1 namespace,
I'm adding two different elements to both std::list and std::set and I want the
I have container in my class like this: protected: std::map<const AAA*, std::set<BBB*> > conn;
They're both resizable arrays, and std::basic_string doesn't have any specifically character-related functions like upper().

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.