summaryrefslogtreecommitdiff
path: root/AK
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-11-07 20:38:24 +0100
committerAndreas Kling <awesomekling@gmail.com>2019-11-07 20:38:33 +0100
commit870be9d71ecf9e552ac7cb673b482b22666edcdf (patch)
tree3a0a9297987c5edbc2e4ff186931e0464358b2d7 /AK
parentd6f9349f15d3a1e309ee48eb20d07ef950078568 (diff)
downloadserenity-870be9d71ecf9e552ac7cb673b482b22666edcdf.zip
AK: Add Vector::take(index)
This removes an item from the vector and returns it.
Diffstat (limited to 'AK')
-rw-r--r--AK/Vector.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/AK/Vector.h b/AK/Vector.h
index 76c96d05b8..012b23ae27 100644
--- a/AK/Vector.h
+++ b/AK/Vector.h
@@ -263,6 +263,13 @@ public:
return value;
}
+ T take(int index)
+ {
+ T value = move(at(index));
+ remove(index);
+ return value;
+ }
+
void remove(int index)
{
ASSERT(index < m_size);