Change signature of Insert method to return indication of whether insertion succeeded

This commit is contained in:
Tim Flynn 2016-11-14 13:17:42 -05:00
parent fd1327031b
commit 08e977efe5

View File

@ -89,7 +89,7 @@ public:
return nCurrentSize;
}
void Insert(const K& key, const V& value)
bool Insert(const K& key, const V& value)
{
if(nCurrentSize == nMaxSize) {
PruneLast();
@ -102,7 +102,7 @@ public:
if(mapIt.count(value) > 0) {
// Don't insert duplicates
return;
return false;
}
listItems.push_front(item_t(key, value));
@ -110,6 +110,7 @@ public:
mapIt[value] = lit;
++nCurrentSize;
return true;
}
bool HasKey(const K& key) const