fix some example and readme
This commit is contained in:
10
README.md
10
README.md
@@ -9,15 +9,15 @@
|
||||
Что тут:
|
||||
+ audio - набор методов по работе со звуком: воспроизведение, запись, работа с массивом звуков и т.п.
|
||||
+ concepts - набор разнообразных реализаций концептов
|
||||
+ math - разные математические функции
|
||||
+ range - работа с последовательностями
|
||||
+ patterns - набор различных паттернов проектирования
|
||||
+ security - что-то типа защиты от чего-то
|
||||
+ utils - вспомогательные решения для библиотеки
|
||||
|
||||
- exception - универсальный класс обработки ошибок
|
||||
- iterators - набор разнообразных реализаций итераторов
|
||||
- logger - реализация логирования
|
||||
- math - разные математические функции
|
||||
- patterns - набор различных паттернов проектирования
|
||||
- range - работа с последовательностями
|
||||
- security - что-то типа защиты от чего-то
|
||||
- utils - вспомогательные решения для библиотеки
|
||||
|
||||
+ - задукоментированно с коментариями и примерами
|
||||
- - доки в раборте, нужно делать и разбирать
|
||||
|
||||
13
bin/examples/math/main.cpp
Normal file
13
bin/examples/math/main.cpp
Normal 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;
|
||||
}
|
||||
|
||||
29
bin/examples/patterns/main.cpp
Normal file
29
bin/examples/patterns/main.cpp
Normal 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;
|
||||
}
|
||||
|
||||
21
bin/examples/range/main.cpp
Normal file
21
bin/examples/range/main.cpp
Normal 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;
|
||||
}
|
||||
|
||||
1
bin/examples/range/range.delemiter.txt
Normal file
1
bin/examples/range/range.delemiter.txt
Normal file
@@ -0,0 +1 @@
|
||||
1:2:3:4:4:4:6
|
||||
1
bin/examples/range/range.txt
Normal file
1
bin/examples/range/range.txt
Normal file
@@ -0,0 +1 @@
|
||||
1, 2, 3, 4, 4, 4, 6
|
||||
79
bin/main.cpp
79
bin/main.cpp
@@ -1,79 +0,0 @@
|
||||
#include <vector>
|
||||
#include <forward_list>
|
||||
|
||||
#include "hack/logger/logger.hpp"
|
||||
|
||||
#include "hack/range/sort.hpp"
|
||||
#include "hack/range/save_to_file.hpp"
|
||||
#include "hack/math/max.hpp"
|
||||
|
||||
#include "hack/patterns/ring_buffer.hpp"
|
||||
#include "hack/patterns/identificator.hpp"
|
||||
|
||||
// #include "hack/security/uuid.hpp"
|
||||
|
||||
auto main(int argc, char *argv[]) -> int
|
||||
{
|
||||
// HERE
|
||||
// concepts
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// patterns::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);
|
||||
}
|
||||
|
||||
// security
|
||||
{
|
||||
// hack::log()(hack::security::generate_uuid());
|
||||
}
|
||||
|
||||
// patterns::identificator
|
||||
{
|
||||
struct a : public hack::patterns::identificator<>
|
||||
{} aa;
|
||||
a bb;
|
||||
a cc;
|
||||
a dd;
|
||||
hack::log()(aa.m_id, bb.m_id, cc.m_id, dd.m_id);
|
||||
}
|
||||
|
||||
// range::sort
|
||||
{
|
||||
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/test/range.txt", v);
|
||||
hack::range::save_to_file("/mnt/raid/projects/hack/hack/bin/test/range.delemiter.txt", v, ":");
|
||||
}
|
||||
|
||||
// math::max
|
||||
{
|
||||
int a = 4, b = 5;
|
||||
int& c = a;
|
||||
hack::log()(hack::math::max(4, 5));
|
||||
hack::log()(hack::math::max(c, b));
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,10 @@
|
||||
executable(
|
||||
meson.project_name(),
|
||||
# 'examples/audio/main.cpp',
|
||||
'examples/concepts/main.cpp',
|
||||
# 'examples/concepts/main.cpp',
|
||||
# 'examples/math/main.cpp',
|
||||
# 'examples/range/main.cpp',
|
||||
'examples/patterns/main.cpp',
|
||||
dependencies : deps,
|
||||
cpp_args: args,
|
||||
include_directories : inc
|
||||
|
||||
@@ -4,6 +4,9 @@
|
||||
|
||||
namespace hack::patterns
|
||||
{
|
||||
// Иногда нужно, чтобы был id но в виде какого-то числа.
|
||||
// Например при выводе графики в массиве, типа как в VueJS
|
||||
// вот этьо класс и пытается этим заниматься.
|
||||
template<typename T = std::size_t>
|
||||
class identificator
|
||||
{
|
||||
|
||||
@@ -9,6 +9,9 @@
|
||||
|
||||
namespace hack::patterns
|
||||
{
|
||||
// Колцевой буфер.
|
||||
// HERE
|
||||
// сделать опсание каждой функции
|
||||
template<typename T>
|
||||
class ring_buffer
|
||||
{
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace hack::patterns
|
||||
{
|
||||
// Синглетон, говорит сам за себя...
|
||||
struct no_copy
|
||||
{
|
||||
no_copy() = default;
|
||||
|
||||
Reference in New Issue
Block a user