Change signature of Insert method to return indication of whether insertion succeeded
This commit is contained in:
parent
fd1327031b
commit
08e977efe5
@ -89,7 +89,7 @@ public:
|
|||||||
return nCurrentSize;
|
return nCurrentSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Insert(const K& key, const V& value)
|
bool Insert(const K& key, const V& value)
|
||||||
{
|
{
|
||||||
if(nCurrentSize == nMaxSize) {
|
if(nCurrentSize == nMaxSize) {
|
||||||
PruneLast();
|
PruneLast();
|
||||||
@ -102,7 +102,7 @@ public:
|
|||||||
|
|
||||||
if(mapIt.count(value) > 0) {
|
if(mapIt.count(value) > 0) {
|
||||||
// Don't insert duplicates
|
// Don't insert duplicates
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
listItems.push_front(item_t(key, value));
|
listItems.push_front(item_t(key, value));
|
||||||
@ -110,6 +110,7 @@ public:
|
|||||||
|
|
||||||
mapIt[value] = lit;
|
mapIt[value] = lit;
|
||||||
++nCurrentSize;
|
++nCurrentSize;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HasKey(const K& key) const
|
bool HasKey(const K& key) const
|
||||||
|
Loading…
Reference in New Issue
Block a user