From 08ec58f347948e9a62e63d6c17501f12b39965ea Mon Sep 17 00:00:00 2001 From: Ali Mohammad Pur Date: Wed, 16 Oct 2024 15:42:23 +0200 Subject: [PATCH] AK: Add OrderedHashMap::take_first() This is just a convenience shortcut for *take(begin()->key). --- AK/HashMap.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/AK/HashMap.h b/AK/HashMap.h index 22abc069529..c4c72bbcfdc 100644 --- a/AK/HashMap.h +++ b/AK/HashMap.h @@ -243,6 +243,12 @@ public: return {}; } + V take_first() + requires(IsOrdered) + { + return take(begin()->key).release_value(); + } + V& ensure(K const& key) { auto it = find(key);