diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-11-07 20:38:24 +0100 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-11-07 20:38:33 +0100 |
commit | 870be9d71ecf9e552ac7cb673b482b22666edcdf (patch) | |
tree | 3a0a9297987c5edbc2e4ff186931e0464358b2d7 /AK | |
parent | d6f9349f15d3a1e309ee48eb20d07ef950078568 (diff) | |
download | serenity-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.h | 7 |
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); |