summaryrefslogtreecommitdiff
path: root/kernel
diff options
context:
space:
mode:
authorClifford Wolf <clifford@clifford.at>2014-12-28 22:26:09 +0100
committerClifford Wolf <clifford@clifford.at>2014-12-28 22:26:09 +0100
commitdede5353b10c1d8fb887fbfd3a46cb1fc0413082 (patch)
treef98bc106c54ad27342bba2f09edf3bf870660a62 /kernel
parent2ad131764fc9b9b3f913650d206a540c2d57dc45 (diff)
Some changes to hashlib to make for better stl compatibility
Diffstat (limited to 'kernel')
-rw-r--r--kernel/hashlib.h26
1 files changed, 14 insertions, 12 deletions
diff --git a/kernel/hashlib.h b/kernel/hashlib.h
index e5e76a1e..24a1dbf6 100644
--- a/kernel/hashlib.h
+++ b/kernel/hashlib.h
@@ -200,13 +200,13 @@ class dict
}
}
- void do_erase(const K &key, int hash)
+ int do_erase(const K &key, int hash)
{
int last_index = -1;
int index = hashtable.empty() ? -1 : hashtable[hash];
while (1) {
if (index < 0)
- return;
+ return 0;
if (ops.cmp(entries[index].udata.first, key)) {
if (last_index < 0)
hashtable[hash] = entries[index].get_next();
@@ -219,7 +219,7 @@ class dict
clear();
else if (index == begin_n)
do begin_n--; while (begin_n >= 0 && entries[begin_n].is_free());
- return;
+ return 1;
}
last_index = index;
index = entries[index].get_next();
@@ -355,16 +355,17 @@ public:
return std::pair<iterator, bool>(iterator(this, i), true);
}
- void erase(const K &key)
+ int erase(const K &key)
{
int hash = mkhash(key);
- do_erase(key, hash);
+ return do_erase(key, hash);
}
- void erase(const iterator it)
+ iterator erase(iterator it)
{
int hash = mkhash(it->first);
do_erase(it->first, hash);
+ return ++it;
}
int count(const K &key) const
@@ -538,13 +539,13 @@ class pool
}
}
- void do_erase(const K &key, int hash)
+ int do_erase(const K &key, int hash)
{
int last_index = -1;
int index = hashtable.empty() ? -1 : hashtable[hash];
while (1) {
if (index < 0)
- return;
+ return 0;
if (ops.cmp(entries[index].key, key)) {
if (last_index < 0)
hashtable[hash] = entries[index].get_next();
@@ -557,7 +558,7 @@ class pool
clear();
else if (index == begin_n)
do begin_n--; while (begin_n >= 0 && entries[begin_n].is_free());
- return;
+ return 1;
}
last_index = index;
index = entries[index].get_next();
@@ -693,16 +694,17 @@ public:
return std::pair<iterator, bool>(iterator(this, i), true);
}
- void erase(const K &key)
+ int erase(const K &key)
{
int hash = mkhash(key);
- do_erase(key, hash);
+ return do_erase(key, hash);
}
- void erase(const iterator it)
+ iterator erase(iterator it)
{
int hash = mkhash(*it);
do_erase(*it, hash);
+ return ++it;
}
int count(const K &key) const