mirror of
https://github.com/holub/mame
synced 2025-04-26 18:23:08 +03:00
util::fifo.queue_length() (nw)
Not 100% confident about the variable type, and there may still be some debate over the function name (trying to avoid confusion with the length of the container, or with the number of empty slots), so appreciate review/comments.
This commit is contained in:
parent
56ae477b84
commit
ece4404b69
@ -885,6 +885,17 @@ public:
|
||||
bool full() const { return !m_empty && (m_head == m_tail); }
|
||||
bool empty() const { return m_empty; }
|
||||
|
||||
// number of currently enqueued elements
|
||||
std::size_t queue_length() const
|
||||
{
|
||||
if (m_empty)
|
||||
return 0;
|
||||
|
||||
auto const distance = std::distance(m_head, m_tail);
|
||||
|
||||
return (distance > 0) ? distance : (N + distance);
|
||||
}
|
||||
|
||||
void enqueue(T const &v)
|
||||
{
|
||||
if (WriteWrap || m_empty || (m_head != m_tail))
|
||||
|
Loading…
Reference in New Issue
Block a user