From bd66449412199cf24093518c136d4a3eaba79c15 Mon Sep 17 00:00:00 2001 From: Stephen Anthony Date: Wed, 14 Aug 2019 13:43:32 -0230 Subject: [PATCH] Working on FileListWidget, and keep forgetting to commit this bit. --- src/common/LinkedObjectPool.hxx | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/common/LinkedObjectPool.hxx b/src/common/LinkedObjectPool.hxx index 88582af84..0da278bca 100644 --- a/src/common/LinkedObjectPool.hxx +++ b/src/common/LinkedObjectPool.hxx @@ -112,6 +112,22 @@ class LinkedObjectPool myCurrent = std::next(myCurrent, 1); } + /** + Advance 'current' iterator to first position in the active list. + */ + void moveToFirst() { + if(currentIsValid()) + myCurrent = myList.begin(); + } + + /** + Advance 'current' iterator to last position in the active list. + */ + void moveToLast() { + if(currentIsValid()) + myCurrent = std::prev(myList.end(), 1); + } + /** Return an iterator to the first node in the active list. */ @@ -246,6 +262,13 @@ class LinkedObjectPool bool empty() const { return size() == 0; } bool full() const { return size() >= capacity(); } + friend ostream& operator<<(ostream& os, const LinkedObjectPool& p) { + for(const auto& i: p.myList) + os << i << (p.current() == i ? "* " : " "); + return os; + + } + private: std::list myList, myPool;