Commit f173daf3 authored by Valentin Valls's avatar Valentin Valls

Update unordered_map to match C++11

- bucket API
- load_factor API
- erase and insert with begin/end iterators
parent a5d0bb1b
......@@ -41,7 +41,7 @@ cdef extern from "<unordered_map>" namespace "std" nogil:
iterator end()
const_iterator const_end "end"()
pair[iterator, iterator] equal_range(T&)
#pair[const_iterator, const_iterator] equal_range(key_type&)
pair[const_iterator, const_iterator] const_equal_range "equal_range"(const T&)
iterator erase(iterator)
iterator erase(iterator, iterator)
size_t erase(T&)
......@@ -49,7 +49,7 @@ cdef extern from "<unordered_map>" namespace "std" nogil:
const_iterator const_find "find"(T&)
pair[iterator, bint] insert(pair[T, U]) # XXX pair[T,U]&
iterator insert(iterator, pair[T, U]) # XXX pair[T,U]&
#void insert(input_iterator, input_iterator)
iterator insert(iterator, iterator)
#key_compare key_comp()
iterator lower_bound(T&)
const_iterator const_lower_bound "lower_bound"(T&)
......@@ -65,5 +65,9 @@ cdef extern from "<unordered_map>" namespace "std" nogil:
#value_compare value_comp()
void max_load_factor(float)
float max_load_factor()
void rehash(size_t)
void reserve(size_t)
size_t bucket_count()
size_t max_bucket_count()
size_t bucket_size(size_t)
size_t bucket(const T&)
......@@ -133,6 +133,7 @@ def test_unordered_map_functionality():
pair[int, int] pair_insert = pair[int, int](1, 2)
unordered_map[int,int].iterator iterator = int_map.begin()
pair[unordered_map[int,int].iterator, bint] pair_iter = int_map.insert(pair_insert)
unordered_map[int, int] int_map2
assert int_map[1] == 2
assert int_map.size() == 1
assert int_map.erase(1) == 1 # returns number of elements erased
......@@ -142,6 +143,22 @@ def test_unordered_map_functionality():
assert int_map[1] == 2
iterator = int_map.find(1)
assert int_map.erase(iterator) == int_map.end()
return "pass"
int_map2[1] = 2
int_map2[3] = 3
int_map.clear()
int_map.insert(int_map2.begin(), int_map2.end())
assert int_map.size() == 2
assert int_map.erase(int_map.begin(), int_map.end()) == int_map.end()
int_map.max_load_factor(0.5)
assert int_map.max_load_factor() == 0.5
int_map.rehash(20)
int_map.reserve(20)
int_map[3] = 3
int_map.bucket_size(0)
int_map.bucket_count()
int_map.max_bucket_count()
int_map.bucket(3)
return "pass"
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment