summaryrefslogtreecommitdiff
path: root/ucoo
diff options
context:
space:
mode:
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 ()
{