Skip to content

Commit 47463a3

Browse files
committed
Use std::size_t instead of unsigned in the sharing map
1 parent 3e22217 commit 47463a3

File tree

2 files changed

+16
-20
lines changed

2 files changed

+16
-20
lines changed

src/util/sharing_map.h

+12-16
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ class sharing_mapt
132132
typedef sharing_mapt<key_type, mapped_type, hash, key_equal> self_type;
133133
typedef sharing_nodet<key_type, mapped_type, key_equal> node_type;
134134

135-
typedef size_t size_type;
135+
typedef std::size_t size_type;
136136

137137
/// Return type of methods that retrieve a const reference to a value. First
138138
/// component is a reference to the value (or a dummy value if the given key
@@ -165,13 +165,13 @@ class sharing_mapt
165165
static const std::string not_found_msg;
166166

167167
/// Number of bits in the hash deemed significant
168-
static const size_t bits;
168+
static const std::size_t bits;
169169

170170
/// Size of a chunk of the hash that represents a character
171-
static const size_t chunk;
171+
static const std::size_t chunk;
172172

173-
static const size_t mask;
174-
static const size_t steps;
173+
static const std::size_t mask;
174+
static const std::size_t steps;
175175

176176
// interface
177177

@@ -536,9 +536,9 @@ SHARING_MAPT2(, node_type *)::get_container_node(const key_type &k)
536536
size_t key=hash()(k);
537537
node_type *p=&map;
538538

539-
for(unsigned i=0; i<steps; i++)
539+
for(std::size_t i = 0; i < steps; i++)
540540
{
541-
unsigned bit=key&mask;
541+
std::size_t bit = key & mask;
542542
key>>=chunk;
543543

544544
p=p->add_child(bit);
@@ -552,9 +552,9 @@ SHARING_MAPT2(const, node_type *)::get_container_node(const key_type &k) const
552552
size_t key=hash()(k);
553553
const node_type *p=&map;
554554

555-
for(unsigned i=0; i<steps; i++)
555+
for(std::size_t i = 0; i < steps; i++)
556556
{
557-
unsigned bit=key&mask;
557+
std::size_t bit = key & mask;
558558
key>>=chunk;
559559

560560
p=p->find_child(bit);
@@ -598,14 +598,14 @@ SHARING_MAPT2(, size_type)::erase(
598598
return 0;
599599

600600
node_type *del=nullptr;
601-
unsigned del_bit = 0;
601+
std::size_t del_bit = 0;
602602

603603
size_t key=hash()(k);
604604
node_type *p=&map;
605605

606-
for(unsigned i=0; i<steps; i++)
606+
for(std::size_t i = 0; i < steps; i++)
607607
{
608-
unsigned bit=key&mask;
608+
std::size_t bit = key & mask;
609609
key>>=chunk;
610610

611611
const subt &sub=as_const(p)->get_sub();
@@ -712,8 +712,6 @@ SHARING_MAPT2(, const_find_type)::insert(
712712
///
713713
/// \param k: The key of the element to insert
714714
/// \param m: The mapped value to insert
715-
/// \param key_exists: Hint to indicate whether the element is known to exist
716-
/// (possible values false or unknown)
717715
/// \return Pair of reference to existing or newly inserted element, and boolean
718716
/// indicating if new element was inserted
719717
SHARING_MAPT2(, find_type)::place(
@@ -778,8 +776,6 @@ SHARING_MAPT2(, find_type)::find(
778776
/// - Best case: O(H)
779777
///
780778
/// \param k: The key of the element to search
781-
/// \param key_exists: Hint to indicate whether the element is known to exist
782-
/// (possible values `unknown` or `true`)
783779
/// \return Pair of const reference to found value (or dummy value if not
784780
/// found), and boolean indicating if element was found.
785781
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)