summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-11-03 12:09:19 +0100
committerAndreas Kling <awesomekling@gmail.com>2019-11-03 12:09:19 +0100
commit78a744da7768a6ba1ec8a300a504647531e9ce86 (patch)
tree30ec0aa03e3d879b0af528bbe9f09ae06bdb6113
parentc1d3ac7108e2530b928f93d0dffe4d7a902f1f85 (diff)
downloadserenity-78a744da7768a6ba1ec8a300a504647531e9ce86.zip
AK: Add Queue::head()
This returns a const T& for the first element in the queue, without dequeuing it.
-rw-r--r--AK/Queue.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/AK/Queue.h b/AK/Queue.h
index 7a21c51b3a..157e07ea07 100644
--- a/AK/Queue.h
+++ b/AK/Queue.h
@@ -40,6 +40,12 @@ public:
return value;
}
+ const T& head() const
+ {
+ ASSERT(!is_empty());
+ return (*m_segments.first())[m_index_into_first];
+ }
+
void clear()
{
m_segments.clear();