fix some example and readme

This commit is contained in:
2025-09-05 18:48:48 +03:00
parent 0418fce44c
commit 00d96e3e2c
11 changed files with 81 additions and 85 deletions

View File

@@ -0,0 +1,13 @@
#include "hack/math/max.hpp"
#include "hack/logger/logger.hpp"
auto main(int argc, char *argv[]) -> int
{
int a = 4, b = 5;
int& c = a;
hack::log()(hack::math::max(4, 5));
hack::log()(hack::math::max(c, b));
return 0;
}

View File

@@ -0,0 +1,29 @@
#include "hack/patterns/ring_buffer.hpp"
#include "hack/patterns/identificator.hpp"
#include "hack/logger/logger.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);
hack::log()(rb.size());
rb.skip(3);
hack::log()(rb.get().value());
hack::log()(rb.size());
std::vector<int> v(3);
rb.get(v, 3);
hack::log()(v);
// 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);
return 0;
}

View File

@@ -0,0 +1,21 @@
#include "hack/range/save_to_file.hpp"
#include "hack/range/sort.hpp"
#include "hack/logger/logger.hpp"
auto main(int argc, char *argv[]) -> int
{
std::vector<int> v { 4, 4, 6, 1, 4, 3, 2 };
std::forward_list<int> l { 8, 7, 5, 9, 0, 1, 3, 2, 6, 4 };
hack::range::sort(v);
hack::range::sort(l);
hack::log()(v);
hack::log()(l);
hack::range::save_to_file("/mnt/raid/projects/hack/hack/bin/examples/range/range.txt", v);
hack::range::save_to_file("/mnt/raid/projects/hack/hack/bin/examples/range/range.delemiter.txt", v, ":");
return 0;
}

View File

@@ -0,0 +1 @@
1:2:3:4:4:4:6

View File

@@ -0,0 +1 @@
1, 2, 3, 4, 4, 4, 6