summaryrefslogtreecommitdiff
path: root/ucoo
diff options
context:
space:
mode:
authorNicolas Schodet2015-08-31 09:45:42 +0200
committerNicolas Schodet2019-10-07 00:44:50 +0200
commitdf84a4f0d40981e9aab14af11a96af5ef8da8692 (patch)
treef49ce4267a698fa226eb7ce71737458d19c8dbbb /ucoo
parent6718de7e40e35e8e66d5311d51acd7944139143e (diff)
ucoo/utils: add Fifo::top
Diffstat (limited to 'ucoo')
-rw-r--r--ucoo/utils/fifo.hh3
-rw-r--r--ucoo/utils/fifo.tcc8
2 files changed, 11 insertions, 0 deletions
diff --git a/ucoo/utils/fifo.hh b/ucoo/utils/fifo.hh
index f80caf9..38c1e4f 100644
--- a/ucoo/utils/fifo.hh
+++ b/ucoo/utils/fifo.hh
@@ -43,6 +43,9 @@ class Fifo
bool empty () const { return head_ == tail_; }
/// Test whether the FIFO is full.
bool full () const { return head_ == next (tail_); }
+ /// Return a reference to top (next to be popped) element, do not do that
+ /// if FIFO is empty!
+ T &top ();
/// Remove an element, do not do that if FIFO is empty!
T pop ();
/// Add an element, do not do that if FIFO is full!
diff --git a/ucoo/utils/fifo.tcc b/ucoo/utils/fifo.tcc
index be8f896..9612605 100644
--- a/ucoo/utils/fifo.tcc
+++ b/ucoo/utils/fifo.tcc
@@ -35,6 +35,14 @@ Fifo<T, size>::Fifo ()
}
template<typename T, int size>
+T &
+Fifo<T, size>::top ()
+{
+ assert (head_ != tail_);
+ return buffer_[head_];
+}
+
+template<typename T, int size>
inline T
Fifo<T, size>::pop ()
{