add new ring buffer
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
#include "hack/patterns/ring_buffer.hpp"
|
||||
#include "hack/patterns/identificator.hpp"
|
||||
#include "hack/logger/logger.hpp"
|
||||
#include "hack/patterns/ring_buffer.hpp"
|
||||
|
||||
auto main(int argc, char *argv[]) -> int
|
||||
{
|
||||
@@ -8,21 +8,34 @@ auto main(int argc, char *argv[]) -> int
|
||||
hack::patterns::ring_buffer<int> rb;
|
||||
rb.create(10);
|
||||
for (int i = 0; i < 10; ++i) rb.put(i);
|
||||
hack::log()(rb);
|
||||
hack::log()(rb.size());
|
||||
hack::log()("rb =", rb);
|
||||
hack::log()("size =", rb.size());
|
||||
rb.skip(3);
|
||||
hack::log()(rb.pop().value());
|
||||
hack::log()("size =", rb.size());
|
||||
hack::log()(rb.get().value());
|
||||
hack::log()(rb.size());
|
||||
hack::log()("size =", rb.size());
|
||||
std::vector<int> v(3);
|
||||
rb.get(v, 3);
|
||||
hack::log()(v);
|
||||
hack::log()("rb =", rb);
|
||||
hack::log()("v =", v);
|
||||
rb.pop(v, 5);
|
||||
hack::log()("v =", v);
|
||||
hack::log()(rb.pop().value());
|
||||
hack::log()("rb =", rb);
|
||||
hack::log()("rb:", rb.pop().has_value(), " (пусто...)");
|
||||
rb.put(1);
|
||||
hack::log()("rb =", rb);
|
||||
hack::log()(rb.pop().value());
|
||||
hack::log()("rb =", rb);
|
||||
hack::log()("rb:", rb.pop().has_value(), " (пусто...)");
|
||||
|
||||
// identificator
|
||||
struct id_struct : public hack::patterns::identificator<> {} aa;
|
||||
id_struct bb;
|
||||
id_struct cc;
|
||||
id_struct dd;
|
||||
hack::log()(aa.m_id, bb.m_id, cc.m_id, dd.m_id);
|
||||
hack::log()(aa.get_id(), bb.get_id(), cc.get_id(), dd.get_id());
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user