Files
hack/bin/examples/patterns/main.cpp
2025-09-15 11:16:00 +03:00

46 lines
1.2 KiB
C++

#include "hack/patterns/identificator.hpp"
#include "hack/logger/logger.hpp"
#include "hack/patterns/ring_buffer.hpp"
auto main(int argc, char *argv[]) -> int
{
// ring_buffer
hack::patterns::ring_buffer<int> rb;
rb.create(10);
for (int i = 0; i < 10; ++i) rb.put(i);
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()("size =", rb.size());
std::vector<int> v(3);
rb.get(v, 3);
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(), " (пусто...)");
rb.put(v);
hack::log()("rb =", rb);
// identificator
struct id_struct : public hack::patterns::identificator<> {} aa;
id_struct bb;
id_struct cc;
id_struct dd;
hack::log()("identificator:");
hack::log()(aa.get_id(), bb.get_id(), cc.get_id(), dd.get_id());
return 0;
}