Skip to content

Commit 5f35d26

Browse files
committed
Use std::size_t instead of unsigned in the sharing map
1 parent 6d35961 commit 5f35d26

File tree

2 files changed

+18
-22
lines changed

2 files changed

+18
-22
lines changed

src/util/sharing_map.h

+14-18
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ class sharing_mapt
126126
typedef sharing_mapt<key_type, mapped_type, hash, key_equal> self_type;
127127
typedef sharing_nodet<key_type, mapped_type, key_equal> node_type;
128128

129-
typedef size_t size_type;
129+
typedef std::size_t size_type;
130130

131131
/// Return type of methods that retrieve a const reference to a value. First
132132
/// component is a reference to the value (or a dummy value if the given key
@@ -159,13 +159,13 @@ class sharing_mapt
159159
static const std::string not_found_msg;
160160

161161
/// Number of bits in the hash deemed significant
162-
static const size_t bits;
162+
static const std::size_t bits;
163163

164164
/// Size of a chunk of the hash that represents a character
165-
static const size_t chunk;
165+
static const std::size_t chunk;
166166

167-
static const size_t mask;
168-
static const size_t steps;
167+
static const std::size_t mask;
168+
static const std::size_t steps;
169169

170170
// interface
171171

@@ -530,9 +530,9 @@ SHARING_MAPT2(, node_type *)::get_container_node(const key_type &k)
530530
size_t key=hash()(k);
531531
node_type *p=&map;
532532

533-
for(unsigned i=0; i<steps; i++)
533+
for(std::size_t i=0; i<steps; i++)
534534
{
535-
unsigned bit=key&mask;
535+
std::size_t bit=key&mask;
536536
key>>=chunk;
537537

538538
p=p->add_child(bit);
@@ -546,9 +546,9 @@ SHARING_MAPT2(const, node_type *)::get_container_node(const key_type &k) const
546546
size_t key=hash()(k);
547547
const node_type *p=&map;
548548

549-
for(unsigned i=0; i<steps; i++)
549+
for(std::size_t i=0; i<steps; i++)
550550
{
551-
unsigned bit=key&mask;
551+
std::size_t bit=key&mask;
552552
key>>=chunk;
553553

554554
p=p->find_child(bit);
@@ -592,14 +592,14 @@ SHARING_MAPT2(, size_type)::erase(
592592
return 0;
593593

594594
node_type *del=nullptr;
595-
unsigned del_bit=0;
595+
std::size_t del_bit = 0;
596596

597597
size_t key=hash()(k);
598598
node_type *p=&map;
599599

600-
for(unsigned i=0; i<steps; i++)
600+
for(std::size_t i=0; i<steps; i++)
601601
{
602-
unsigned bit=key&mask;
602+
std::size_t bit=key&mask;
603603
key>>=chunk;
604604

605605
const subt &sub=as_const(p)->get_sub();
@@ -614,9 +614,9 @@ SHARING_MAPT2(, size_type)::erase(
614614

615615
_sm_assert(p->is_container());
616616

617-
const containert &c=as_const(p)->get_container();
617+
const containert &c = as_const(p)->get_container();
618618

619-
if(c.size()==1)
619+
if(c.size() == 1)
620620
{
621621
del->remove_child(del_bit);
622622
num--;
@@ -706,8 +706,6 @@ SHARING_MAPT2(, const_find_type)::insert(
706706
///
707707
/// \param k: The key of the element to insert
708708
/// \param m: The mapped value to insert
709-
/// \param key_exists: Hint to indicate whether the element is known to exist
710-
/// (possible values false or unknown)
711709
/// \return Pair of reference to existing or newly inserted element, and boolean
712710
/// indicating if new element was inserted
713711
SHARING_MAPT2(, find_type)::place(
@@ -772,8 +770,6 @@ SHARING_MAPT2(, find_type)::find(
772770
/// - Best case: O(H)
773771
///
774772
/// \param k: The key of the element to search
775-
/// \param key_exists: Hint to indicate whether the element is known to exist
776-
/// (possible values `unknown` or `true`)
777773
/// \return Pair of const reference to found value (or dummy value if not
778774
/// found), and boolean indicating if element was found.
779775
SHARING_MAPT2(, const_find_type)::find(const key_type &k) const

src/util/sharing_node.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class sharing_nodet
4545

4646
typedef sharing_nodet<key_type, mapped_type, key_equal> self_type;
4747

48-
typedef std::map<unsigned, self_type> subt;
48+
typedef std::map<std::size_t, self_type> subt;
4949
typedef std::list<self_type> containert;
5050

5151
typedef const std::pair<const self_type &, const bool> const_find_type;
@@ -156,7 +156,7 @@ class sharing_nodet
156156

157157
// internal nodes
158158

159-
const self_type *find_child(const unsigned n) const
159+
const self_type *find_child(const std::size_t n) const
160160
{
161161
const subt &s=get_sub();
162162
typename subt::const_iterator it=s.find(n);
@@ -167,13 +167,13 @@ class sharing_nodet
167167
return nullptr;
168168
}
169169

170-
self_type *add_child(const unsigned n)
170+
self_type *add_child(const std::size_t n)
171171
{
172172
subt &s=get_sub();
173173
return &s[n];
174174
}
175175

176-
void remove_child(const unsigned n)
176+
void remove_child(const std::size_t n)
177177
{
178178
subt &s=get_sub();
179179
size_t r=s.erase(n);

0 commit comments

Comments
 (0)