public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "tinrow at gmail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug libstdc++/61667] New: setting max_load_factor of unordered_map cause buckets shrink
Date: Wed, 02 Jul 2014 09:10:00 -0000	[thread overview]
Message-ID: <bug-61667-4@http.gcc.gnu.org/bugzilla/> (raw)

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61667

            Bug ID: 61667
           Summary: setting max_load_factor of unordered_map cause buckets
                    shrink
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: tinrow at gmail dot com

I want to build an unordered_map with at least 200000 initial buckets and set
max load factor to 0.5. The bucket count shrinks to 2 during call to
max_load_factor.

Reproduce:
$ cat 1.cpp 
#include <unordered_map>
#include <iostream>

using namespace std;

int main () {
  unordered_map<int, int> m(200000);
  cout << m.bucket_count() << endl;
  m.max_load_factor(0.5);
  cout << m.bucket_count() << endl;
  return 0;
}

$ g++ -std=c++11 1.cpp 
$ ./a.out 
202409
2

$ g++ --version
g++ (GCC) 4.8.2

In the ISO/IEC 14882:2011 standard, here is a possible "increase" but no
"shrink".

b.max_load_factor() float
Returns a positive number that the container attempts to keep the load factor
less than or equal to. The container automatically increases the number of
buckets as necessary to keep the load factor below this number.


             reply	other threads:[~2014-07-02  9:10 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-02  9:10 tinrow at gmail dot com [this message]
2014-07-02  9:43 ` [Bug libstdc++/61667] " redi at gcc dot gnu.org
2014-07-23 20:07 ` fdumont at gcc dot gnu.org
2014-08-09  8:01 ` fdumont at gcc dot gnu.org
2014-08-09 10:19 ` fdumont at gcc dot gnu.org
2014-08-10  0:45 ` redi at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-61667-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).