diff --git a/Hash_map/include/CGAL/Tools/chained_map.h b/Hash_map/include/CGAL/Tools/chained_map.h index 351a239f44a..042065b77db 100644 --- a/Hash_map/include/CGAL/Tools/chained_map.h +++ b/Hash_map/include/CGAL/Tools/chained_map.h @@ -76,11 +76,10 @@ private: public: static constexpr std::size_t min_size = 32; static constexpr std::size_t default_size = 512; - typedef chained_map_elem* chained_map_item; - typedef chained_map_item item; + typedef chained_map_elem* Item; - std::size_t index(chained_map_item it) const { return it->k; } - T& inf(chained_map_item it) const { return it->i; } + std::size_t index(Item it) const { return it->k; } + T& inf(Item it) const { return it->i; } chained_map(std::size_t n = default_size, const T& d = T()); chained_map(const chained_map& D); @@ -92,14 +91,14 @@ public: { if(!table) return; - for (chained_map_item item = table ; item != table_end ; ++item) + for (Item item = table ; item != table_end ; ++item) destroy(item); alloc.deallocate(table, table_end - table); } - T& access(chained_map_item p, std::size_t x); + T& access(Item p, std::size_t x); T& access(std::size_t x); - chained_map_item lookup(std::size_t x) const; + Item lookup(std::size_t x) const; void statistics() const; }; @@ -109,7 +108,7 @@ inline T& chained_map::access(std::size_t x) if(!table) init_table(reserved_size); - chained_map_item p = HASH(x); + Item p = HASH(x); if ( p->k == x ) { return p->i; @@ -140,7 +139,7 @@ void chained_map::init_table(std::size_t n) free = table + t; table_end = table + t + t/2; - for (chained_map_item p = table; p < free; p++) + for (Item p = table; p < free; p++) { p->succ = nullptr; p->k = nullptrKEY; } @@ -149,7 +148,7 @@ void chained_map::init_table(std::size_t n) template inline void chained_map::insert(std::size_t x, T y) -{ chained_map_item q = HASH(x); +{ Item q = HASH(x); if ( q->k == nullptrKEY ) { q->k = x; q->i = y; @@ -169,16 +168,16 @@ void chained_map::rehash() chained_map_elem* old_table_end = table_end; chained_map_elem* old_free = free; - chained_map_item old_table_mid = table + table_size; + Item old_table_mid = table + table_size; init_table(2*table_size); - chained_map_item p; + Item p; for(p = old_table; p < old_table_mid; p++) { std::size_t x = p->k; if ( x != nullptrKEY ) // list p is non-empty - { chained_map_item q = HASH(x); + { Item q = HASH(x); q->k = x; q->i = p->i; } @@ -190,16 +189,16 @@ void chained_map::rehash() p++; } - for (chained_map_item item = old_table ; item != old_table_end ; ++item) + for (Item item = old_table ; item != old_table_end ; ++item) destroy(item); alloc.deallocate(old_table, old_table_end - old_table); } template -T& chained_map::access(chained_map_item p, std::size_t x) +T& chained_map::access(Item p, std::size_t x) { - chained_map_item q = p->succ; + Item q = p->succ; while (q && q->k != x) q = q->succ; if (q) { @@ -240,7 +239,7 @@ chained_map::chained_map(const chained_map& D) { init_table(D.table_size); - for(chained_map_item p = D.table; p < D.free; p++) + for(Item p = D.table; p < D.free; p++) { if (p->k != nullptrKEY || p >= D.table + D.table_size) { insert(p->k,p->i); //D.copy_inf(p->i); // see chapter Implementation @@ -255,7 +254,7 @@ chained_map& chained_map::operator=(const chained_ma init_table(D.table_size); - for(chained_map_item p = D.table; p < D.free; p++) + for(Item p = D.table; p < D.free; p++) { if (p->k != nullptrKEY || p >= D.table + D.table_size) { insert(p->k,p->i); //copy_inf(p->i); // see chapter Implementation @@ -277,7 +276,7 @@ void chained_map::clear() if(!table) return; - for (chained_map_item item = table ; item != table_end ; ++item) + for (Item item = table ; item != table_end ; ++item) destroy(item); alloc.deallocate(table, table_end - table); @@ -285,13 +284,13 @@ void chained_map::clear() } template -typename chained_map::chained_map_item +typename chained_map::Item chained_map::lookup(std::size_t x) const { if(!table) return nullptr; - chained_map_item p = HASH(x); + Item p = HASH(x); while (p && p->k != x) { p = p->succ; } return p; @@ -301,7 +300,7 @@ template void chained_map::statistics() const { std::cout << "table_size: " << table_size <<"\n"; std::size_t n = 0; - for (chained_map_item p = table; p < table + table_size; p++) + for (Item p = table; p < table + table_size; p++) if (p ->k != nullptrKEY) n++; std::size_t used_in_overflow = free - (table + table_size ); n += used_in_overflow; diff --git a/Hash_map/include/CGAL/Unique_hash_map.h b/Hash_map/include/CGAL/Unique_hash_map.h index 58e830a34c1..09d3dc9610c 100644 --- a/Hash_map/include/CGAL/Unique_hash_map.h +++ b/Hash_map/include/CGAL/Unique_hash_map.h @@ -47,7 +47,7 @@ public: private: typedef internal::chained_map Map; - typedef typename Map::item Item; + typedef typename Map::Item Item; private: Hash_function m_hash_function;