aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaolo Carlini <pcarlini@suse.de>2006-02-07 15:11:10 +0000
committerPaolo Carlini <paolo@gcc.gnu.org>2006-02-07 15:11:10 +0000
commit774b9d213ac7f52fd74f3aca414775356fb6770c (patch)
tree6b18e0d7498ee480393dbe729f6b39f4e25f8acf
parent4f0de5dd33ec2f8eb0aa43da72d9cc493478f077 (diff)
downloadgcc-774b9d213ac7f52fd74f3aca414775356fb6770c.zip
gcc-774b9d213ac7f52fd74f3aca414775356fb6770c.tar.gz
gcc-774b9d213ac7f52fd74f3aca414775356fb6770c.tar.bz2
[multiple changes]
2006-02-07 Paolo Carlini <pcarlini@suse.de> * include/tr1/hashtable: Trivial formatting fixes. 2006-02-07 Paolo Carlini <pcarlini@suse.de> Zak Kipling <zak@transversal.com> PR libstdc++/26127 * include/tr1/hashtable (hashtable<>::key_equal): Define. (hashtable<>::bucket, rehash_base<>::max_load_factor): Fix. * testsuite/tr1/6_containers/unordered/hashtable/26127.cc: New. Co-Authored-By: Zak Kipling <zak@transversal.com> From-SVN: r110697
-rw-r--r--libstdc++-v3/ChangeLog12
-rw-r--r--libstdc++-v3/include/tr1/hashtable49
-rw-r--r--libstdc++-v3/testsuite/tr1/6_containers/unordered/hashtable/26127.cc39
3 files changed, 80 insertions, 20 deletions
diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog
index c356685..6648933 100644
--- a/libstdc++-v3/ChangeLog
+++ b/libstdc++-v3/ChangeLog
@@ -1,3 +1,15 @@
+2006-02-07 Paolo Carlini <pcarlini@suse.de>
+
+ * include/tr1/hashtable: Trivial formatting fixes.
+
+2006-02-07 Paolo Carlini <pcarlini@suse.de>
+ Zak Kipling <zak@transversal.com>
+
+ PR libstdc++/26127
+ * include/tr1/hashtable (hashtable<>::key_equal): Define.
+ (hashtable<>::bucket, rehash_base<>::max_load_factor): Fix.
+ * testsuite/tr1/6_containers/unordered/hashtable/26127.cc: New.
+
2006-02-07 Paolo Carlini <pcarlini@suse.de>
* include/tr1/cmath: New.
diff --git a/libstdc++-v3/include/tr1/hashtable b/libstdc++-v3/include/tr1/hashtable
index 0b9bc41..e9b73c6 100644
--- a/libstdc++-v3/include/tr1/hashtable
+++ b/libstdc++-v3/include/tr1/hashtable
@@ -653,7 +653,7 @@ namespace Internal
max_load_factor() const
{
const Hashtable* This = static_cast<const Hashtable*>(this);
- return This->rehash_policy()->max_load_factor();
+ return This->rehash_policy().max_load_factor();
}
void
@@ -836,7 +836,7 @@ namespace Internal
typedef std::size_t hash_code_t;
hash_code_t
- m_hash_code (const Key& k) const
+ m_hash_code(const Key& k) const
{ return m_h1(k); }
std::size_t
@@ -1081,6 +1081,13 @@ _GLIBCXX_BEGIN_NAMESPACE(tr1)
max_size() const
{ return m_node_allocator.max_size(); }
+ public: // Observers
+ key_equal
+ key_eq() const
+ { return this->m_eq; }
+
+ // hash_function, if present, comes from hash_code_base.
+
public: // Bucket operations
size_type
bucket_count() const
@@ -1094,9 +1101,11 @@ _GLIBCXX_BEGIN_NAMESPACE(tr1)
bucket_size(size_type n) const
{ return std::distance(begin(n), end(n)); }
- size_type bucket(const key_type& k) const
+ size_type
+ bucket(const key_type& k) const
{
- return this->bucket_index(k, this->m_hash_code, this->m_bucket_count);
+ return this->bucket_index(k, this->m_hash_code(k),
+ this->m_bucket_count);
}
local_iterator
@@ -1477,9 +1486,9 @@ _GLIBCXX_BEGIN_NAMESPACE(tr1)
hashtable<K, V, A, Ex, Eq, H1, H2, H, RP, c, ci, u>::
find(const key_type& k)
{
- typename hashtable::hash_code_t code = this->m_hash_code (k);
+ typename hashtable::hash_code_t code = this->m_hash_code(k);
std::size_t n = this->bucket_index(k, code, this->bucket_count());
- node* p = find_node (m_buckets[n], k, code);
+ node* p = find_node(m_buckets[n], k, code);
return p ? iterator(p, m_buckets + n) : this->end();
}
@@ -1491,9 +1500,9 @@ _GLIBCXX_BEGIN_NAMESPACE(tr1)
hashtable<K, V, A, Ex, Eq, H1, H2, H, RP, c, ci, u>::
find(const key_type& k) const
{
- typename hashtable::hash_code_t code = this->m_hash_code (k);
+ typename hashtable::hash_code_t code = this->m_hash_code(k);
std::size_t n = this->bucket_index(k, code, this->bucket_count());
- node* p = find_node (m_buckets[n], k, code);
+ node* p = find_node(m_buckets[n], k, code);
return p ? const_iterator(p, m_buckets + n) : this->end();
}
@@ -1505,11 +1514,11 @@ _GLIBCXX_BEGIN_NAMESPACE(tr1)
hashtable<K, V, A, Ex, Eq, H1, H2, H, RP, c, ci, u>::
count(const key_type& k) const
{
- typename hashtable::hash_code_t code = this->m_hash_code (k);
- std::size_t n = this->bucket_index (k, code, this->bucket_count());
+ typename hashtable::hash_code_t code = this->m_hash_code(k);
+ std::size_t n = this->bucket_index(k, code, this->bucket_count());
size_t result = 0;
for (node* p = m_buckets[n]; p ; p = p->m_next)
- if (this->compare (k, code, p))
+ if (this->compare(k, code, p))
++result;
return result;
}
@@ -1525,7 +1534,7 @@ _GLIBCXX_BEGIN_NAMESPACE(tr1)
hashtable<K, V, A, Ex, Eq, H1, H2, H, RP, c, ci, u>::
equal_range(const key_type& k)
{
- typename hashtable::hash_code_t code = this->m_hash_code (k);
+ typename hashtable::hash_code_t code = this->m_hash_code(k);
std::size_t n = this->bucket_index(k, code, this->bucket_count());
node** head = m_buckets + n;
node* p = find_node (*head, k, code);
@@ -1558,16 +1567,16 @@ _GLIBCXX_BEGIN_NAMESPACE(tr1)
hashtable<K, V, A, Ex, Eq, H1, H2, H, RP, c, ci, u>::
equal_range(const key_type& k) const
{
- typename hashtable::hash_code_t code = this->m_hash_code (k);
+ typename hashtable::hash_code_t code = this->m_hash_code(k);
std::size_t n = this->bucket_index(k, code, this->bucket_count());
node** head = m_buckets + n;
- node* p = find_node (*head, k, code);
+ node* p = find_node(*head, k, code);
if (p)
{
node* p1 = p->m_next;
for (; p1 ; p1 = p1->m_next)
- if (!this->compare (k, code, p1))
+ if (!this->compare(k, code, p1))
break;
const_iterator first(p, head);
@@ -1608,7 +1617,7 @@ _GLIBCXX_BEGIN_NAMESPACE(tr1)
insert(const value_type& v, std::tr1::true_type)
{
const key_type& k = this->m_extract(v);
- typename hashtable::hash_code_t code = this->m_hash_code (k);
+ typename hashtable::hash_code_t code = this->m_hash_code(k);
size_type n = this->bucket_index(k, code, m_bucket_count);
if (node* p = find_node(m_buckets[n], k, code))
@@ -1657,7 +1666,7 @@ _GLIBCXX_BEGIN_NAMESPACE(tr1)
m_rehash(do_rehash.second);
const key_type& k = this->m_extract(v);
- typename hashtable::hash_code_t code = this->m_hash_code (k);
+ typename hashtable::hash_code_t code = this->m_hash_code(k);
size_type n = this->bucket_index(k, code, m_bucket_count);
node* new_node = m_allocate_node (v);
@@ -1760,15 +1769,15 @@ _GLIBCXX_BEGIN_NAMESPACE(tr1)
hashtable<K, V, A, Ex, Eq, H1, H2, H, RP, c, ci, u>::
erase(const key_type& k)
{
- typename hashtable::hash_code_t code = this->m_hash_code (k);
+ typename hashtable::hash_code_t code = this->m_hash_code(k);
size_type n = this->bucket_index(k, code, m_bucket_count);
size_type result = 0;
node** slot = m_buckets + n;
- while (*slot && ! this->compare (k, code, *slot))
+ while (*slot && ! this->compare(k, code, *slot))
slot = &((*slot)->m_next);
- while (*slot && this->compare (k, code, *slot))
+ while (*slot && this->compare(k, code, *slot))
{
node* n = *slot;
*slot = n->m_next;
diff --git a/libstdc++-v3/testsuite/tr1/6_containers/unordered/hashtable/26127.cc b/libstdc++-v3/testsuite/tr1/6_containers/unordered/hashtable/26127.cc
new file mode 100644
index 0000000..d14a625
--- /dev/null
+++ b/libstdc++-v3/testsuite/tr1/6_containers/unordered/hashtable/26127.cc
@@ -0,0 +1,39 @@
+// { dg-do compile }
+
+// Copyright (C) 2006 Free Software Foundation, Inc.
+//
+// This file is part of the GNU ISO C++ Library. This library is free
+// software; you can redistribute it and/or modify it under the
+// terms of the GNU General Public License as published by the
+// Free Software Foundation; either version 2, or (at your option)
+// any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this library; see the file COPYING. If not, write to the Free
+// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
+// USA.
+
+// 6.3 Unordered associative containers
+
+#include <tr1/unordered_set>
+
+// libstdc++/26127
+void test01()
+{
+ std::tr1::unordered_set<int> s;
+
+ s.bucket(42);
+ s.key_eq();
+ s.max_load_factor();
+}
+
+int main()
+{
+ test01();
+ return 0;
+}