From 47463a382dbc59b0734e5d247bfeb6326770cb5c Mon Sep 17 00:00:00 2001 From: Daniel Poetzl Date: Mon, 23 Apr 2018 17:39:43 +0100 Subject: [PATCH] Use std::size_t instead of unsigned in the sharing map --- src/util/sharing_map.h | 28 ++++++++++++---------------- src/util/sharing_node.h | 8 ++++---- 2 files changed, 16 insertions(+), 20 deletions(-) diff --git a/src/util/sharing_map.h b/src/util/sharing_map.h index d9579c449ad..23da0dedda6 100644 --- a/src/util/sharing_map.h +++ b/src/util/sharing_map.h @@ -132,7 +132,7 @@ class sharing_mapt typedef sharing_mapt self_type; typedef sharing_nodet node_type; - typedef size_t size_type; + typedef std::size_t size_type; /// Return type of methods that retrieve a const reference to a value. First /// component is a reference to the value (or a dummy value if the given key @@ -165,13 +165,13 @@ class sharing_mapt static const std::string not_found_msg; /// Number of bits in the hash deemed significant - static const size_t bits; + static const std::size_t bits; /// Size of a chunk of the hash that represents a character - static const size_t chunk; + static const std::size_t chunk; - static const size_t mask; - static const size_t steps; + static const std::size_t mask; + static const std::size_t steps; // interface @@ -536,9 +536,9 @@ SHARING_MAPT2(, node_type *)::get_container_node(const key_type &k) size_t key=hash()(k); node_type *p=↦ - for(unsigned i=0; i>=chunk; p=p->add_child(bit); @@ -552,9 +552,9 @@ SHARING_MAPT2(const, node_type *)::get_container_node(const key_type &k) const size_t key=hash()(k); const node_type *p=↦ - for(unsigned i=0; i>=chunk; p=p->find_child(bit); @@ -598,14 +598,14 @@ SHARING_MAPT2(, size_type)::erase( return 0; node_type *del=nullptr; - unsigned del_bit = 0; + std::size_t del_bit = 0; size_t key=hash()(k); node_type *p=↦ - for(unsigned i=0; i>=chunk; const subt &sub=as_const(p)->get_sub(); @@ -712,8 +712,6 @@ SHARING_MAPT2(, const_find_type)::insert( /// /// \param k: The key of the element to insert /// \param m: The mapped value to insert -/// \param key_exists: Hint to indicate whether the element is known to exist -/// (possible values false or unknown) /// \return Pair of reference to existing or newly inserted element, and boolean /// indicating if new element was inserted SHARING_MAPT2(, find_type)::place( @@ -778,8 +776,6 @@ SHARING_MAPT2(, find_type)::find( /// - Best case: O(H) /// /// \param k: The key of the element to search -/// \param key_exists: Hint to indicate whether the element is known to exist -/// (possible values `unknown` or `true`) /// \return Pair of const reference to found value (or dummy value if not /// found), and boolean indicating if element was found. SHARING_MAPT2(, const_find_type)::find(const key_type &k) const diff --git a/src/util/sharing_node.h b/src/util/sharing_node.h index 9cec1cd2f3a..2c279c486ed 100644 --- a/src/util/sharing_node.h +++ b/src/util/sharing_node.h @@ -45,7 +45,7 @@ class sharing_nodet typedef sharing_nodet self_type; - typedef std::map subt; + typedef std::map subt; typedef std::list containert; typedef const std::pair const_find_type; @@ -156,7 +156,7 @@ class sharing_nodet // internal nodes - const self_type *find_child(const unsigned n) const + const self_type *find_child(const std::size_t n) const { const subt &s=get_sub(); typename subt::const_iterator it=s.find(n); @@ -167,13 +167,13 @@ class sharing_nodet return nullptr; } - self_type *add_child(const unsigned n) + self_type *add_child(const std::size_t n) { subt &s=get_sub(); return &s[n]; } - void remove_child(const unsigned n) + void remove_child(const std::size_t n) { subt &s=get_sub(); size_t r=s.erase(n);