mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 18:37:35 +00:00
AK: Add Ordering support to HashTable and HashMap
Adds a IsOrdered flag to Hashtable and HashMap, which allows iteration in insertion order
This commit is contained in:
parent
c69ea44397
commit
4a81c79909
3 changed files with 136 additions and 26 deletions
|
@ -19,7 +19,7 @@
|
|||
|
||||
namespace AK {
|
||||
|
||||
template<typename K, typename V, typename KeyTraits>
|
||||
template<typename K, typename V, typename KeyTraits, bool IsOrdered>
|
||||
class HashMap {
|
||||
private:
|
||||
struct Entry {
|
||||
|
@ -68,7 +68,7 @@ public:
|
|||
}
|
||||
void remove_one_randomly() { m_table.remove(m_table.begin()); }
|
||||
|
||||
using HashTableType = HashTable<Entry, EntryTraits>;
|
||||
using HashTableType = HashTable<Entry, EntryTraits, IsOrdered>;
|
||||
using IteratorType = typename HashTableType::Iterator;
|
||||
using ConstIteratorType = typename HashTableType::ConstIterator;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue