mirror of
https://github.com/holub/mame
synced 2025-10-05 08:41:31 +03:00
Added 'poke' and 'clear' methods to fifo template
This commit is contained in:
parent
d9f7237a7a
commit
f1a1b77595
@ -428,7 +428,7 @@ public:
|
|||||||
fifo()
|
fifo()
|
||||||
: std::array<T, N>()
|
: std::array<T, N>()
|
||||||
, m_head(this->begin())
|
, m_head(this->begin())
|
||||||
, m_tail(this->end())
|
, m_tail(this->begin())
|
||||||
, m_empty(true)
|
, m_empty(true)
|
||||||
{
|
{
|
||||||
static_assert(0U < N, "FIFO must have at least one element");
|
static_assert(0U < N, "FIFO must have at least one element");
|
||||||
@ -513,11 +513,28 @@ public:
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void poke(T &v)
|
||||||
|
{
|
||||||
|
*m_tail = v;
|
||||||
|
}
|
||||||
|
|
||||||
|
void poke(T &&v)
|
||||||
|
{
|
||||||
|
*m_tail = std::move(v);
|
||||||
|
}
|
||||||
|
|
||||||
T const &peek() const
|
T const &peek() const
|
||||||
{
|
{
|
||||||
return *m_head;
|
return *m_head;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void clear() const
|
||||||
|
{
|
||||||
|
m_head = m_tail = this->begin();
|
||||||
|
m_empty = true;
|
||||||
|
return *m_head;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typename fifo::iterator m_head, m_tail;
|
typename fifo::iterator m_head, m_tail;
|
||||||
bool m_empty;
|
bool m_empty;
|
||||||
|
Loading…
Reference in New Issue
Block a user