add patterns ring buffer peek
This commit is contained in:
47
bin/main.cpp
47
bin/main.cpp
@@ -13,29 +13,34 @@ auto main(int argc, char *argv[]) -> int
|
||||
// patterns::ring_buffer
|
||||
{
|
||||
hack::patterns::ring_buffer<int> rb(10);
|
||||
for (int i = 1; i < 12; ++i) rb.put(i);
|
||||
for (int i = 0; i < 10; ++i) rb.put(i);
|
||||
hack::log()(rb);
|
||||
}
|
||||
|
||||
// mt::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::mt::algorithms::sort(v);
|
||||
hack::mt::algorithms::sort(l);
|
||||
|
||||
hack::log()(rb.size());
|
||||
rb.skip(3);
|
||||
hack::log()(rb.get().value());
|
||||
hack::log()(rb.size());
|
||||
std::vector<int> v(3);
|
||||
rb.peek(v, 3);
|
||||
hack::log()(v);
|
||||
hack::log()(l);
|
||||
}
|
||||
|
||||
// mt::max
|
||||
{
|
||||
int a = 4, b = 5;
|
||||
int& c = a;
|
||||
hack::log()(hack::mt::algorithms::max(4, 5));
|
||||
hack::log()(hack::mt::algorithms::max(c, b));
|
||||
}
|
||||
|
||||
hack::error()("asdfJK");
|
||||
// // mt::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::mt::algorithms::sort(v);
|
||||
// hack::mt::algorithms::sort(l);
|
||||
//
|
||||
// hack::log()(v);
|
||||
// hack::log()(l);
|
||||
// }
|
||||
//
|
||||
// // mt::max
|
||||
// {
|
||||
// int a = 4, b = 5;
|
||||
// int& c = a;
|
||||
// hack::log()(hack::mt::algorithms::max(4, 5));
|
||||
// hack::log()(hack::mt::algorithms::max(c, b));
|
||||
// }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user