Merge pull request #4782

2e5361b remove code below asserts in limitedmap.h (fixes a ToDo) (Philip Kaufmann)
pull/4968/merge
Wladimir J. van der Laan 10 years ago
commit 82e370b4b0
No known key found for this signature in database
GPG Key ID: 74810B012346C9A6

@ -1,11 +1,11 @@
// Copyright (c) 2012 The Bitcoin developers // Copyright (c) 2012-2014 The Bitcoin developers
// Distributed under the MIT/X11 software license, see the accompanying // Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php. // file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef BITCOIN_LIMITEDMAP_H #ifndef BITCOIN_LIMITEDMAP_H
#define BITCOIN_LIMITEDMAP_H #define BITCOIN_LIMITEDMAP_H
#include <assert.h> // TODO: remove #include <assert.h>
#include <map> #include <map>
/** STL-like map container that only keeps the N elements with the highest value. */ /** STL-like map container that only keeps the N elements with the highest value. */
@ -59,12 +59,11 @@ public:
return; return;
} }
// Shouldn't ever get here // Shouldn't ever get here
assert(0); //TODO remove me assert(0);
map.erase(itTarget);
} }
void update(const_iterator itIn, const mapped_type& v) void update(const_iterator itIn, const mapped_type& v)
{ {
//TODO: When we switch to C++11, use map.erase(itIn, itIn) to get the non-const iterator // TODO: When we switch to C++11, use map.erase(itIn, itIn) to get the non-const iterator.
iterator itTarget = map.find(itIn->first); iterator itTarget = map.find(itIn->first);
if (itTarget == map.end()) if (itTarget == map.end())
return; return;
@ -77,9 +76,7 @@ public:
return; return;
} }
// Shouldn't ever get here // Shouldn't ever get here
assert(0); //TODO remove me assert(0);
itTarget->second = v;
rmap.insert(make_pair(v, itTarget));
} }
size_type max_size() const { return nMaxSize; } size_type max_size() const { return nMaxSize; }
size_type max_size(size_type s) size_type max_size(size_type s)

Loading…
Cancel
Save