mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-01 05:39:11 +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
Notes:
sideshowbarker
2024-07-18 12:13:01 +09:00
Author: https://github.com/Hendiadyoin1
Commit: 4a81c79909
Pull-request: https://github.com/SerenityOS/serenity/pull/8041
Reviewed-by: https://github.com/IdanHo
Reviewed-by: https://github.com/alimpfard
Reviewed-by: https://github.com/awesomekling
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