[09_queue] add traverse function.

This commit is contained in:
Liam Huang 2018-10-10 21:53:38 +08:00
parent af91fa84a8
commit b2cb8db35a

View File

@ -84,6 +84,14 @@ class ArrayQueue {
throw "Pop data from an empty queue!";
}
}
public:
template <typename UnaryFunc>
void traverse(UnaryFunc do_traverse) {
for (size_t i = head_; i != tail_; ++i) {
do_traverse(items_[i]);
}
}
};
#endif // QUEUE_ARRAY_QUEUE_HPP_