1a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner#include <vector>
2a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner#include <algorithm>
3a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner#include <string>
4a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner#if defined (STLPORT)
5a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner#  include <unordered_map>
6a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner#  include <unordered_set>
7a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner#endif
8a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner
9a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner//#include <iostream>
10a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner
11a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner#include "cppunit/cppunit_proxy.h"
12a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner
13a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner#if !defined (STLPORT) || defined(_STLP_USE_NAMESPACES)
14a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turnerusing namespace std;
15a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner#  if defined (STLPORT)
16a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turnerusing namespace std::tr1;
17a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner#  endif
18a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner#endif
19a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner
20a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner//
21a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner// TestCase class
22a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner//
23a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turnerclass UnorderedTest : public CPPUNIT_NS::TestCase
24a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner{
25a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  CPPUNIT_TEST_SUITE(UnorderedTest);
26a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner#if !defined (STLPORT)
27a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  CPPUNIT_IGNORE;
28a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner#endif
29a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  CPPUNIT_TEST(uset);
30a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  CPPUNIT_TEST(umultiset);
31a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  CPPUNIT_TEST(umap);
32a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  CPPUNIT_TEST(umultimap);
33a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  CPPUNIT_TEST(user_case);
34a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  CPPUNIT_TEST(hash_policy);
35a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  CPPUNIT_TEST(buckets);
36a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  CPPUNIT_TEST(equal_range);
37a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  CPPUNIT_EXPLICIT_TEST(benchmark1);
38a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  CPPUNIT_EXPLICIT_TEST(benchmark2);
39a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner#if !defined (_STLP_USE_CONTAINERS_EXTENSION)
40a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  CPPUNIT_IGNORE;
41a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner#endif
42a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  CPPUNIT_TEST(template_methods);
43a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  CPPUNIT_TEST_SUITE_END();
44a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner
45a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turnerprotected:
46a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  void uset();
47a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  void umultiset();
48a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  void umap();
49a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  void umultimap();
50a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  void user_case();
51a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  void hash_policy();
52a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  void buckets();
53a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  void equal_range();
54a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  void benchmark1();
55a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  void benchmark2();
56a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  void template_methods();
57a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner};
58a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner
59a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' TurnerCPPUNIT_TEST_SUITE_REGISTRATION(UnorderedTest);
60a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner
61a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turnerconst int NB_ELEMS = 2000;
62a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner
63a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner//
64a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner// tests implementation
65a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner//
66a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turnervoid UnorderedTest::uset()
67a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner{
68a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner#if defined (STLPORT)
69a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  typedef unordered_set<int, hash<int>, equal_to<int> > usettype;
70a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  usettype us;
71a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner
72a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  //Small compilation check of the copy constructor:
73a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  usettype us2(us);
74a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  //And assignment operator
75a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  us = us2;
76a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner
77a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  int i;
78a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  pair<usettype::iterator, bool> ret;
79a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  for (i = 0; i < NB_ELEMS; ++i) {
80a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    ret = us.insert(i);
81a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    CPPUNIT_ASSERT( ret.second );
82a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    CPPUNIT_ASSERT( *ret.first == i );
83a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner
84a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    ret = us.insert(i);
85a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    CPPUNIT_ASSERT( !ret.second );
86a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    CPPUNIT_ASSERT( *ret.first == i );
87a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  }
88a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner
89a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  vector<int> us_val;
90a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner
91a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  usettype::local_iterator lit, litEnd;
92a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  for (i = 0; i < NB_ELEMS; ++i) {
93a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    lit = us.begin(us.bucket(i));
94a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    litEnd = us.end(us.bucket(i));
95a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner
96a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    usettype::size_type bucket_pos = us.bucket(*lit);
97a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    for (; lit != litEnd; ++lit) {
98a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner      CPPUNIT_ASSERT( us.bucket(*lit) == bucket_pos );
99a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner      us_val.push_back(*lit);
100a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    }
101a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  }
102a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner
103a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  //A compilation time check to uncomment from time to time
104a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  {
105a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    //usettype::iterator it;
106a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    //CPPUNIT_ASSERT( it != lit );
107a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  }
108a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner
109a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  sort(us_val.begin(), us_val.end());
110a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  for (i = 0; i < NB_ELEMS; ++i) {
111a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    CPPUNIT_ASSERT( us_val[i] == i );
112a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  }
113a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner#endif
114a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner}
115a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner
116a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turnervoid UnorderedTest::umultiset()
117a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner{
118a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner#if defined (STLPORT)
119a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  typedef unordered_multiset<int, hash<int>, equal_to<int> > usettype;
120a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  usettype us;
121a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner
122a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  int i;
123a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  usettype::iterator ret;
124a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  for (i = 0; i < NB_ELEMS; ++i) {
125a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    ret = us.insert(i);
126a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    CPPUNIT_ASSERT( *ret == i );
127a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner
128a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    ret = us.insert(i);
129a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    CPPUNIT_ASSERT( *ret == i );
130a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  }
131a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner
132a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  CPPUNIT_ASSERT( us.size() == 2 * NB_ELEMS );
133a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  vector<int> us_val;
134a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner
135a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  usettype::local_iterator lit, litEnd;
136a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  for (i = 0; i < NB_ELEMS; ++i) {
137a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    lit = us.begin(us.bucket(i));
138a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    litEnd = us.end(us.bucket(i));
139a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner
140a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    usettype::size_type bucket_pos = us.bucket(*lit);
141a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    for (; lit != litEnd; ++lit) {
142a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner      CPPUNIT_ASSERT( us.bucket(*lit) == bucket_pos );
143a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner      us_val.push_back(*lit);
144a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    }
145a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  }
146a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner
147a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  sort(us_val.begin(), us_val.end());
148a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  for (i = 0; i < NB_ELEMS; ++i) {
149a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    CPPUNIT_ASSERT( us_val[2 * i] == i );
150a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    CPPUNIT_ASSERT( us_val[2 * i + 1] == i );
151a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  }
152a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner#endif
153a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner}
154a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner
155a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turnervoid UnorderedTest::umap()
156a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner{
157a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner#if defined (STLPORT)
158a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  typedef unordered_map<int, int, hash<int>, equal_to<int> > umaptype;
159a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  umaptype us;
160a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner
161a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  //Compilation check of the [] operator:
162a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  umaptype us2;
163a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  us[0] = us2[0];
164a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  us.clear();
165a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner
166a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  {
167a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    //An other compilation check
168a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    typedef unordered_map<int, umaptype> uumaptype;
169a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    uumaptype uus;
170a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    umaptype const& uref = uus[0];
171a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    umaptype ucopy = uus[0];
172a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    ucopy = uref;
173a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    //Avoids warning:
174a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    //(void*)&uref;
175a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  }
176a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner
177a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  int i;
178a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  pair<umaptype::iterator, bool> ret;
179a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  for (i = 0; i < NB_ELEMS; ++i) {
180a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    umaptype::value_type p1(i, i);
181a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    ret = us.insert(p1);
182a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    CPPUNIT_ASSERT( ret.second );
183a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    CPPUNIT_ASSERT( *ret.first == p1 );
184a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner
185a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    umaptype::value_type p2(i, i + 1);
186a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    ret = us.insert(p2);
187a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    CPPUNIT_ASSERT( !ret.second );
188a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    CPPUNIT_ASSERT( *ret.first == p1 );
189a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  }
190a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner
191a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  {
192a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    //Lets look for some values to see if everything is normal:
193a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    umaptype::iterator umit;
194a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    for (int j = 0; j < NB_ELEMS; j += NB_ELEMS / 100) {
195a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner      umit = us.find(j);
196a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner
197a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner      CPPUNIT_ASSERT( umit != us.end() );
198a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner      CPPUNIT_ASSERT( (*umit).second == j );
199a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    }
200a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  }
201a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner
202a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  CPPUNIT_ASSERT( us.size() == (size_t)NB_ELEMS );
203a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  vector<pair<int, int> > us_val;
204a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner
205a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  umaptype::local_iterator lit, litEnd;
206a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  for (i = 0; i < NB_ELEMS; ++i) {
207a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    lit = us.begin(us.bucket(i));
208a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    litEnd = us.end(us.bucket(i));
209a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner
210a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    umaptype::size_type bucket_pos = us.bucket((*lit).first);
211a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    for (; lit != litEnd; ++lit) {
212a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner      CPPUNIT_ASSERT( us.bucket((*lit).first) == bucket_pos );
213a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner      us_val.push_back(make_pair((*lit).first, (*lit).second));
214a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    }
215a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  }
216a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner
217a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  sort(us_val.begin(), us_val.end());
218a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  for (i = 0; i < NB_ELEMS; ++i) {
219a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    CPPUNIT_ASSERT( us_val[i] == make_pair(i, i) );
220a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  }
221a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner#endif
222a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner}
223a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner
224a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turnervoid UnorderedTest::umultimap()
225a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner{
226a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner#if defined (STLPORT)
227a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  typedef unordered_multimap<int, int, hash<int>, equal_to<int> > umaptype;
228a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  umaptype us;
229a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner
230a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  int i;
231a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  umaptype::iterator ret;
232a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  for (i = 0; i < NB_ELEMS; ++i) {
233a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    umaptype::value_type p(i, i);
234a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    ret = us.insert(p);
235a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    CPPUNIT_ASSERT( *ret == p );
236a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner
237a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    ret = us.insert(p);
238a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    CPPUNIT_ASSERT( *ret == p );
239a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  }
240a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner
241a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  CPPUNIT_ASSERT( us.size() == 2 * NB_ELEMS );
242a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  typedef pair<int, int> ptype;
243a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  vector<ptype> us_val;
244a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner
245a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  umaptype::local_iterator lit, litEnd;
246a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  for (i = 0; i < NB_ELEMS; ++i) {
247a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    lit = us.begin(us.bucket(i));
248a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    litEnd = us.end(us.bucket(i));
249a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner
250a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    umaptype::size_type bucket_pos = us.bucket((*lit).first);
251a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    for (; lit != litEnd; ++lit) {
252a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner      CPPUNIT_ASSERT( us.bucket((*lit).first) == bucket_pos );
253a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner      us_val.push_back(ptype((*lit).first, (*lit).second));
254a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    }
255a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  }
256a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner
257a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  sort(us_val.begin(), us_val.end());
258a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  for (i = 0; i < NB_ELEMS; ++i) {
259a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    ptype p(i, i);
260a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    CPPUNIT_ASSERT( us_val[i * 2] == p );
261a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    CPPUNIT_ASSERT( us_val[i * 2 + 1] == p );
262a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  }
263a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner#endif
264a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner}
265a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner
266a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turnervoid UnorderedTest::user_case()
267a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner{
268a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner#if defined (STLPORT)
269a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  typedef unordered_map<int, string> UnorderedMap1;
270a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  typedef unordered_map<int, UnorderedMap1> UnorderedMap2;
271a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner
272a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  UnorderedMap1 foo;
273a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  UnorderedMap2 bar;
274a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner
275a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  foo.insert(UnorderedMap1::value_type(1, string("test1")));
276a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  foo.insert(UnorderedMap1::value_type(2, string("test2")));
277a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  foo.insert(UnorderedMap1::value_type(3, string("test3")));
278a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  foo.insert(UnorderedMap1::value_type(4, string("test4")));
279a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  foo.insert(UnorderedMap1::value_type(5, string("test5")));
280a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner
281a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  bar.insert(UnorderedMap2::value_type(0, foo));
282a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  UnorderedMap2::iterator it = bar.find(0);
283a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  CPPUNIT_ASSERT( it != bar.end() );
284a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner
285a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  UnorderedMap1 &body = it->second;
286a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  UnorderedMap1::iterator cur = body.find(3);
287a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  CPPUNIT_ASSERT( cur != body.end() );
288a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner
289a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  body.erase(body.begin(), body.end());
290a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  CPPUNIT_ASSERT( body.empty() );
291a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner#endif
292a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner}
293a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner
294a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turnervoid UnorderedTest::hash_policy()
295a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner{
296a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner#if defined (STLPORT)
297a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  unordered_set<int> int_uset;
298a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner
299a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  CPPUNIT_ASSERT( int_uset.max_load_factor() == 1.0f );
300a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  CPPUNIT_ASSERT( int_uset.load_factor() == 0.0f );
301a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner
302a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  size_t nbInserts = int_uset.bucket_count() - 1;
303a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  for (int i = 0; (size_t)i < nbInserts; ++i) {
304a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    int_uset.insert(i);
305a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  }
306a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  CPPUNIT_ASSERT( int_uset.size() == nbInserts );
307a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner
308a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  int_uset.max_load_factor(0.5f);
309a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  int_uset.rehash(0);
310a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  CPPUNIT_ASSERT( int_uset.load_factor() < int_uset.max_load_factor() );
311a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner
312a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  size_t bucketsHint = int_uset.bucket_count() + 1;
313a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  int_uset.rehash(bucketsHint);
314a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  CPPUNIT_ASSERT( int_uset.bucket_count() >= bucketsHint );
315a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner
316a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  CPPUNIT_ASSERT( int_uset.key_eq()(10, 10) );
317a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  CPPUNIT_ASSERT( int_uset.hash_function()(10) == 10 );
318a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner#endif
319a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner}
320a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner
321a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turnervoid UnorderedTest::buckets()
322a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner{
323a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner#if defined (STLPORT)
324a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  unordered_set<int> int_uset;
325a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner
326a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  CPPUNIT_ASSERT( int_uset.bucket_count() < int_uset.max_bucket_count() );
327a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner
328a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  int i;
329a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  size_t nbBuckets = int_uset.bucket_count();
330a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  size_t nbInserts = int_uset.bucket_count() - 1;
331a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  for (i = 0; (size_t)i < nbInserts; ++i) {
332a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    int_uset.insert(i);
333a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  }
334a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  CPPUNIT_ASSERT( nbBuckets == int_uset.bucket_count() );
335a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner
336a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  size_t bucketSizes = 0;
337a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  for (i = 0; (size_t)i < nbBuckets; ++i) {
338a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    bucketSizes += int_uset.bucket_size(i);
339a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  }
340a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  CPPUNIT_ASSERT( bucketSizes == int_uset.size() );
341a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner#endif
342a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner}
343a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner
344a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turnervoid UnorderedTest::equal_range()
345a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner{
346a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner#if defined (STLPORT)
347a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  typedef unordered_multiset<size_t> umset;
348a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  {
349a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    //General test
350a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    umset iumset;
351a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    iumset.max_load_factor(10.0f);
352a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner
353a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    size_t nbBuckets = iumset.bucket_count();
354a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner
355a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    for (size_t i = 0; i < nbBuckets; ++i) {
356a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner      iumset.insert(i);
357a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner      iumset.insert(i + nbBuckets);
358a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner      iumset.insert(i + 2 * nbBuckets);
359a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner      iumset.insert(i + 3 * nbBuckets);
360a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner      iumset.insert(i + 4 * nbBuckets);
361a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    }
362a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner
363a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    CPPUNIT_ASSERT( nbBuckets == iumset.bucket_count() );
364a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    CPPUNIT_ASSERT( iumset.size() == 5 * nbBuckets );
365a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner
366a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    pair<umset::iterator, umset::iterator> p = iumset.equal_range(1);
367a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    CPPUNIT_ASSERT( p.first != p.second );
368a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner
369a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    size_t nbElems = iumset.size();
370a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    nbElems -= distance(p.first, p.second);
371a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    for (umset::iterator j = p.first; j != p.second;) {
372a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner      iumset.erase(j++);
373a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    }
374a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner
375a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    CPPUNIT_ASSERT( nbElems == iumset.size() );
376a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner
377a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    p = iumset.equal_range(2);
378a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    CPPUNIT_ASSERT( p.first != p.second );
379a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    nbElems -= distance(p.first, p.second);
380a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    iumset.erase(p.first, p.second);
381a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    CPPUNIT_ASSERT( nbElems == iumset.size() );
382a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  }
383a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner
384a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  {
385a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    //More specific test that tries to put many values in the same bucket
386a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    umset iumset;
387a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner
388a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    size_t i;
389a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    //We are going to add at least 20 values, to get a stable hash container while doing that
390a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    //we force a large number of buckets:
391a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    iumset.rehash(193);
392a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner
393a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    size_t nbBuckets = iumset.bucket_count();
394a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    const size_t targetedBucket = nbBuckets / 2;
395a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner
396a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    //Lets put 10 values in the targeted bucket:
397a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    for (i = 0; i < 10; ++i) {
398a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner      iumset.insert(targetedBucket + (i * nbBuckets));
399a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    }
400a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner
401a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    //We put again 10 values in the targeted bucket and in reverse order:
402a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    for (i = 9; i <= 10; --i) {
403a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner      iumset.insert(targetedBucket + (i * nbBuckets));
404a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    }
405a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner
406a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    //Now we put some more elements until hash container is resized:
407a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    i = 0;
408a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    while (iumset.bucket_count() == nbBuckets) {
409a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner      iumset.insert(i++);
410a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    }
411a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner
412a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    //CPPUNIT_ASSERT( iumset.bucket_size(targetedBucket) == 21 );
413a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner
414a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    pair<umset::iterator, umset::iterator> p = iumset.equal_range(targetedBucket);
415a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    CPPUNIT_ASSERT( p.first != p.second );
416a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    CPPUNIT_ASSERT( distance(p.first, p.second) == 3 );
417a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner
418a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    // Now we remove some elements until hash container is resized:
419a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    nbBuckets = iumset.bucket_count();
420a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    while (iumset.bucket_count() == nbBuckets &&
421a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner           !iumset.empty()) {
422a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner      iumset.erase(iumset.begin());
423a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    }
424a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    CPPUNIT_ASSERT( iumset.load_factor() <= iumset.max_load_factor() );
425a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner
426a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    // Adding an element back shouldn't change number of buckets:
427a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    nbBuckets = iumset.bucket_count();
428a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    iumset.insert(0);
429a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    CPPUNIT_ASSERT( iumset.bucket_count() == nbBuckets );
430a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  }
431a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner
432a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  {
433a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    srand(0);
434a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    for (int runs = 0; runs < 2; ++runs) {
435a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner      size_t magic = rand();
436a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner      umset hum;
437a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner      size_t c = 0;
438a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner      for (int i = 0; i < 10000; ++i) {
439a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner        if ((rand() % 500) == 0) {
440a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner          hum.insert(magic);
441a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner          ++c;
442a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner        }
443a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner        else {
444a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner          size_t r;
445a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner          while ((r = rand()) == magic)
446a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner            ;
447a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner          hum.insert(r);
448a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner        }
449a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner
450a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner        /*
451a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner        if ((float)(hum.size() + 1) / (float)hum.bucket_count() > hum.max_load_factor()) {
452a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner          cout << "Hash container dump: Nb elems: " << hum.size() << ", Nb buckets: " << hum.bucket_count() << "\n";
453a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner          for (size_t b = 0; b < hum.bucket_count(); ++b) {
454a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner            if (hum.bucket_size(b) != 0) {
455a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner              umset::local_iterator litBegin(hum.begin(b)), litEnd(hum.end(b));
456a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner              cout << "B" << b << ": ";
457a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner              for (umset::local_iterator lit = litBegin; lit != litEnd; ++lit) {
458a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner                if (lit != litBegin) {
459a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner                  cout << " - ";
460a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner                }
461a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner                cout << *lit;
462a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner              }
463a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner              cout << "\n";
464a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner            }
465a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner          }
466a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner          cout << endl;
467a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner        }
468a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner        */
469a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner      }
470a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner      CPPUNIT_ASSERT( hum.count(magic) == c );
471a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    }
472a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  }
473a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner#endif
474a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner}
475a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner
476a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turnervoid UnorderedTest::benchmark1()
477a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner{
478a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner#if defined (STLPORT)
479a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  typedef unordered_multiset<size_t> umset;
480a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner
481a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  const size_t target = 500000;
482a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  umset iumset;
483a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  iumset.max_load_factor(10);
484a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  size_t i;
485a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  for (i = 0; i < target; ++i) {
486a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    iumset.insert(i);
487a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  }
488a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner
489a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  for (i = 0; i < target; ++i) {
490a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    iumset.erase(i);
491a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  }
492a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner#endif
493a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner}
494a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner
495a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turnervoid UnorderedTest::benchmark2()
496a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner{
497a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner#if defined (STLPORT)
498a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  typedef unordered_multiset<size_t> umset;
499a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner
500a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  const size_t target = 500000;
501a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  umset iumset;
502a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  iumset.max_load_factor(10);
503a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  size_t i;
504a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  for (i = 0; i < target; ++i) {
505a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    iumset.insert(target - i);
506a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  }
507a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner
508a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  for (i = 0; i < target; ++i) {
509a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    iumset.erase(target - i);
510a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  }
511a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner#endif
512a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner}
513a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner
514a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turnerstruct Key
515a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner{
516a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  Key() : m_data(0) {}
517a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  explicit Key(int data) : m_data(data) {}
518a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner
519a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  int m_data;
520a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner
521a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner#if defined (__DMC__) // slist<_Tp,_Alloc>::remove error
522a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  bool operator==(const Key&) const;
523a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner#endif
524a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner};
525a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner
526a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turnerstruct KeyHash
527a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner{
528a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  size_t operator () (Key key) const
529a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  { return (size_t)key.m_data; }
530a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner
531a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  size_t operator () (int data) const
532a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  { return (size_t)data; }
533a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner};
534a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner
535a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turnerstruct KeyEqual
536a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner{
537a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  bool operator () (Key lhs, Key rhs) const
538a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  { return lhs.m_data == rhs.m_data; }
539a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner
540a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  bool operator () (Key lhs, int rhs) const
541a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  { return lhs.m_data == rhs; }
542a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner
543a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  bool operator () (int lhs, Key rhs) const
544a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  { return lhs == rhs.m_data; }
545a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner};
546a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner
547a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turnerstruct KeyHashPtr
548a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner{
549a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  size_t operator () (Key const volatile *key) const
550a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  { return (size_t)key->m_data; }
551a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner
552a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  size_t operator () (int data) const
553a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  { return (size_t)data; }
554a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner};
555a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner
556a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turnerstruct KeyEqualPtr
557a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner{
558a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  bool operator () (Key const volatile *lhs, Key const volatile *rhs) const
559a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  { return lhs->m_data == rhs->m_data; }
560a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner
561a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  bool operator () (Key const volatile *lhs, int rhs) const
562a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  { return lhs->m_data == rhs; }
563a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner
564a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  bool operator () (int lhs, Key const volatile *rhs) const
565a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  { return lhs == rhs->m_data; }
566a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner};
567a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner
568a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turnervoid UnorderedTest::template_methods()
569a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner{
570a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner#if defined (STLPORT) && defined (_STLP_USE_CONTAINERS_EXTENSION)
571a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  {
572a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    typedef unordered_set<Key, KeyHash, KeyEqual> Container;
573a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    Container cont;
574a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    cont.insert(Key(1));
575a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    cont.insert(Key(2));
576a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    cont.insert(Key(3));
577a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    cont.insert(Key(4));
578a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner
579a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    CPPUNIT_ASSERT( cont.count(Key(1)) == 1 );
580a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    CPPUNIT_ASSERT( cont.count(1) == 1 );
581a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    CPPUNIT_ASSERT( cont.count(5) == 0 );
582a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner
583a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    CPPUNIT_ASSERT( cont.find(2) != cont.end() );
584a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    CPPUNIT_ASSERT( cont.equal_range(2) != make_pair(cont.begin(), cont.end()) );
585a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner
586a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    Container const& ccont = cont;
587a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    CPPUNIT_ASSERT( ccont.find(2) != ccont.end() );
588a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    CPPUNIT_ASSERT( ccont.bucket(2) == ccont.bucket(2) );
589a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    CPPUNIT_ASSERT( ccont.equal_range(2) != make_pair(ccont.begin(), ccont.end()) );
590a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  }
591a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner
592a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  {
593a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    typedef unordered_set<Key*, KeyHashPtr, KeyEqualPtr> Container;
594a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    Container cont;
595a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    Key key1(1), key2(2), key3(3), key4(4);
596a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    cont.insert(&key1);
597a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    cont.insert(&key2);
598a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    cont.insert(&key3);
599a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    cont.insert(&key4);
600a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner
601a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    CPPUNIT_ASSERT( cont.count(1) == 1 );
602a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    CPPUNIT_ASSERT( cont.count(5) == 0 );
603a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner
604a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    CPPUNIT_ASSERT( cont.find(2) != cont.end() );
605a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    CPPUNIT_ASSERT( cont.equal_range(2) != make_pair(cont.begin(), cont.end()) );
606a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner
607a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    Container const& ccont = cont;
608a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    CPPUNIT_ASSERT( ccont.find(2) != ccont.end() );
609a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    CPPUNIT_ASSERT( ccont.bucket(2) == ccont.bucket(2) );
610a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    CPPUNIT_ASSERT( ccont.equal_range(2) != make_pair(ccont.begin(), ccont.end()) );
611a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  }
612a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  {
613a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    typedef unordered_multiset<Key, KeyHash, KeyEqual> Container;
614a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    Container cont;
615a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    cont.insert(Key(1));
616a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    cont.insert(Key(2));
617a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    cont.insert(Key(1));
618a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    cont.insert(Key(2));
619a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner
620a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    CPPUNIT_ASSERT( cont.count(Key(1)) == 2 );
621a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    CPPUNIT_ASSERT( cont.count(1) == 2 );
622a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    CPPUNIT_ASSERT( cont.count(5) == 0 );
623a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner
624a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    CPPUNIT_ASSERT( cont.find(2) != cont.end() );
625a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    CPPUNIT_ASSERT( cont.equal_range(1) != make_pair(cont.end(), cont.end()) );
626a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner
627a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    Container const& ccont = cont;
628a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    CPPUNIT_ASSERT( ccont.find(2) != ccont.end() );
629a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    CPPUNIT_ASSERT( ccont.bucket(2) == ccont.bucket(2) );
630a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    CPPUNIT_ASSERT( ccont.equal_range(2) != make_pair(ccont.end(), ccont.end()) );
631a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  }
632a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner
633a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  {
634a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    typedef unordered_multiset<Key const volatile*, KeyHashPtr, KeyEqualPtr> Container;
635a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    Container cont;
636a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    Key key1(1), key2(2), key3(3), key4(4);
637a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    cont.insert(&key1);
638a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    cont.insert(&key2);
639a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    cont.insert(&key3);
640a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    cont.insert(&key4);
641a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner
642a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    CPPUNIT_ASSERT( cont.count(1) == 1 );
643a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    CPPUNIT_ASSERT( cont.count(5) == 0 );
644a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner
645a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    CPPUNIT_ASSERT( cont.find(2) != cont.end() );
646a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    CPPUNIT_ASSERT( cont.equal_range(2) != make_pair(cont.begin(), cont.end()) );
647a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner
648a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    Container const& ccont = cont;
649a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    CPPUNIT_ASSERT( ccont.find(2) != ccont.end() );
650a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    CPPUNIT_ASSERT( ccont.bucket(2) == ccont.bucket(2) );
651a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    CPPUNIT_ASSERT( ccont.equal_range(2) != make_pair(ccont.begin(), ccont.end()) );
652a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  }
653a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner#endif
654a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner}
655a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner
656a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner#if defined (STLPORT) && \
657a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner    (!defined (_STLP_USE_PTR_SPECIALIZATIONS) || defined (_STLP_CLASS_PARTIAL_SPECIALIZATION))
658a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner#  if !defined (__DMC__)
659a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner/* Simple compilation test: Check that nested types like iterator
660a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner * can be access even if type used to instanciate container is not
661a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner * yet completely defined.
662a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner */
663a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turnerclass IncompleteClass
664a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner{
665a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  unordered_set<IncompleteClass> usinstances;
666a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  typedef unordered_set<IncompleteClass>::iterator usit;
667a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  unordered_multiset<IncompleteClass> usminstances;
668a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  typedef unordered_multiset<IncompleteClass>::iterator usmit;
669a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner
670a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  unordered_map<IncompleteClass, IncompleteClass> uminstances;
671a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  typedef unordered_map<IncompleteClass, IncompleteClass>::iterator umit;
672a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  unordered_multimap<IncompleteClass, IncompleteClass> umminstances;
673a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner  typedef unordered_multimap<IncompleteClass, IncompleteClass>::iterator ummit;
674a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner};
675a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner#  endif
676a9225dc81bae267b3454f3676a9108ecb4c9264fDavid 'Digit' Turner#endif
677