20 template <
typename T,
size_t Capacity>
54 : m_data{ other.m_data }
55 , m_head{ other.m_head }
56 , m_tail{ other.m_tail }
57 , m_size{ other.m_size }
89 std::copy(init.begin(), init.end(),
begin());
131 m_data[m_tail] = value;
132 if (++m_tail == Capacity)
147 m_data[m_tail] = std::move(value);
148 if (++m_tail == Capacity)
163 auto&& retval = std::move(m_data[m_head]);
164 if (++m_head == Capacity)
174 return m_data[(m_tail + Capacity - 1) % Capacity];
178 return m_data[(m_tail + Capacity - 1) % Capacity];
183 return m_data[m_head];
187 return m_data[m_head];
192 return m_data[(m_head + index) % Capacity];
196 return m_data[(m_head + index) % Capacity];
353 return { m_data, m_head, Capacity };
360 return { m_data, m_head + m_size, Capacity };
367 return { m_data, m_head, Capacity };
373 return { m_data, m_head + m_size, Capacity };
380 return { m_data, m_head, Capacity };
387 return { m_data, m_head + m_size, Capacity };
リングバッファ
Definition RingBuffer.hpp:22
reference operator[](size_t index)
Definition RingBuffer.hpp:190
const T * const_pointer
Definition RingBuffer.hpp:31
constexpr size_t capacity() const
capacityを取得
Definition RingBuffer.hpp:94
void push(const_reference value)
バッファの先頭に要素を追加
Definition RingBuffer.hpp:125
std::reverse_iterator< iterator > reverse_iterator
Definition RingBuffer.hpp:32
T & reference
Definition RingBuffer.hpp:28
constexpr bool empty() const
Definition RingBuffer.hpp:113
reference back()
Definition RingBuffer.hpp:172
value_type pop()
バッファの末尾を取得し要素を削除
Definition RingBuffer.hpp:157
T * pointer
Definition RingBuffer.hpp:30
iterator end()
バッファの末尾イテレーターを取得
Definition RingBuffer.hpp:358
const_iterator cend() const
バッファの末尾イテレーターを取得
Definition RingBuffer.hpp:385
reverse_iterator rbegin()
Definition RingBuffer.hpp:394
reverse_iterator rend()
Definition RingBuffer.hpp:403
RingBuffer(std::initializer_list< value_type > init)
Definition RingBuffer.hpp:83
const_reference operator[](size_t index) const
Definition RingBuffer.hpp:194
void resize(size_t size)
バッファサイズを変更
Definition RingBuffer.hpp:108
const_reverse_iterator crbegin() const
Definition RingBuffer.hpp:408
const_reverse_iterator rbegin() const
Definition RingBuffer.hpp:390
void push(value_type &&value)
バッファの先頭に要素を追加
Definition RingBuffer.hpp:141
T value_type
Definition RingBuffer.hpp:27
const_reverse_iterator rend() const
Definition RingBuffer.hpp:399
constexpr RingBuffer(const RingBuffer &other)
コピーコンストラクタ
Definition RingBuffer.hpp:53
const_iterator cbegin() const
バッファの先頭イテレーターを取得
Definition RingBuffer.hpp:378
iterator begin()
バッファの先頭イテレーターを取得
Definition RingBuffer.hpp:351
const_iterator begin() const
バッファの先頭イテレーターを取得
Definition RingBuffer.hpp:365
std::reverse_iterator< const_iterator > const_reverse_iterator
Definition RingBuffer.hpp:33
const_reverse_iterator crend() const
Definition RingBuffer.hpp:413
reference front()
Definition RingBuffer.hpp:181
const_reference back() const
Definition RingBuffer.hpp:176
constexpr size_t size() const
バッファサイズを取得
Definition RingBuffer.hpp:101
const_reference front() const
Definition RingBuffer.hpp:185
constexpr RingBuffer()
コンストラクタ
Definition RingBuffer.hpp:43
constexpr bool full() const
Definition RingBuffer.hpp:118
const_iterator end() const
バッファの末尾イテレーターを取得
Definition RingBuffer.hpp:371
constexpr RingBuffer(size_t size)
デフォルトで初期化しないコンストラクタ
Definition RingBuffer.hpp:75
const T & const_reference
Definition RingBuffer.hpp:29
RingBuffer(size_t size, const_reference value)
デフォルトで初期化するコンストラクタ
Definition RingBuffer.hpp:64
Definition Typedef.hpp:94
Definition RingBuffer.hpp:200
bool operator>(const const_iterator &other) const
Definition RingBuffer.hpp:274
const_iterator operator-=(size_t offset)
Definition RingBuffer.hpp:253
pointer operator->() const
Definition RingBuffer.hpp:222
const_iterator operator+=(size_t offset)
Definition RingBuffer.hpp:248
bool operator<=(const const_iterator &other) const
Definition RingBuffer.hpp:270
bool operator<(const const_iterator &other) const
Definition RingBuffer.hpp:266
const_iterator(pointer data, size_t index, size_t size)
Definition RingBuffer.hpp:211
const_iterator operator+(size_t offset) const
Definition RingBuffer.hpp:236
const_iterator operator-(size_t offset) const
Definition RingBuffer.hpp:240
std::random_access_iterator_tag iterator_category
Definition RingBuffer.hpp:201
const_iterator & operator++()
Definition RingBuffer.hpp:226
bool operator!=(const const_iterator &other) const
Definition RingBuffer.hpp:258
pointer m_data
Definition RingBuffer.hpp:207
const_iterator & operator--()
Definition RingBuffer.hpp:231
bool operator==(const const_iterator &other) const
Definition RingBuffer.hpp:262
size_t m_index
Definition RingBuffer.hpp:208
const T & reference
Definition RingBuffer.hpp:205
std::ptrdiff_t difference_type
Definition RingBuffer.hpp:203
const T * pointer
Definition RingBuffer.hpp:204
T value_type
Definition RingBuffer.hpp:202
bool operator>=(const const_iterator &other) const
Definition RingBuffer.hpp:278
size_t m_size
Definition RingBuffer.hpp:209
difference_type operator-(const const_iterator &other) const
Definition RingBuffer.hpp:244
reference operator[](size_t offset) const
Definition RingBuffer.hpp:282
reference operator*() const
Definition RingBuffer.hpp:218
Definition RingBuffer.hpp:290
iterator operator-=(size_t offset)
Definition RingBuffer.hpp:338
reference operator*()
Definition RingBuffer.hpp:302
T value_type
Definition RingBuffer.hpp:292
iterator(pointer data, size_t index, size_t size)
Definition RingBuffer.hpp:297
difference_type operator-(const iterator &other) const
Definition RingBuffer.hpp:329
iterator operator+=(size_t offset)
Definition RingBuffer.hpp:333
reference operator[](size_t offset)
Definition RingBuffer.hpp:343
iterator operator+(size_t offset) const
Definition RingBuffer.hpp:321
std::random_access_iterator_tag iterator_category
Definition RingBuffer.hpp:291
iterator operator-(size_t offset) const
Definition RingBuffer.hpp:325
std::ptrdiff_t difference_type
Definition RingBuffer.hpp:293
iterator & operator++()
Definition RingBuffer.hpp:311
T * pointer
Definition RingBuffer.hpp:294
iterator & operator--()
Definition RingBuffer.hpp:316
pointer operator->()
Definition RingBuffer.hpp:306
T & reference
Definition RingBuffer.hpp:295