based

Opinionated utility library
git clone git://git.dimitrijedobrota.com/based.git
Log | Files | Refs | README | HACKING | CONTRIBUTING | CODE_OF_CONDUCT | BUILDING

commit69041a34dc38d9e2179b0a5297d47a05ee7d7463
parent2924ad6155a029964bec66a410983f838e1b38d6
authorDimitrije Dobrota <mail@dimitrijedobrota.com>
dateWed, 2 Apr 2025 13:51:32 +0200

Fix spelling and formatting

Diffstat:
Minclude/based/functional.hpp|+++---
Minclude/based/integer.hpp|+++---
Minclude/based/list.hpp|+++++++++++++++---------------
Minclude/based/type_traits.hpp|+-

4 files changed, 22 insertions(+), 22 deletions(-)


diff --git a/include/based/functional.hpp b/include/based/functional.hpp

@@ -137,7 +137,7 @@ template<Transformation F, Integer N>

domain_t<F> power_unary(domain_t<F> x, N n, F f)
{
while (!zero(n)) {
n = predecesor(n);
n = predecessor(n);
x = f(x);
}
return x;

@@ -147,14 +147,14 @@ template<Integer I, BinaryOperation Op>

domain_t<Op> power_left_associated(domain_t<Op> a, I n, Op op)
{
assert(n > 0);
return one(n) ? a : op(power_left_associated(a, predecesor(n), op), a);
return one(n) ? a : op(power_left_associated(a, predecessor(n), op), a);
}
template<Integer I, BinaryOperation Op>
domain_t<Op> power_right_associated(domain_t<Op> a, I n, Op op)
{
assert(n > 0);
return one(n) ? a : op(a, power_right_associated(a, predecesor(n), op));
return one(n) ? a : op(a, power_right_associated(a, predecessor(n), op));
}
template<Integer I, AssociativeBinaryOperation Op>

diff --git a/include/based/integer.hpp b/include/based/integer.hpp

@@ -10,7 +10,7 @@ T successor(T n)

}
template<typename T>
T predecesor(T n)
T predecessor(T n)
{
return n - T {1};
}

@@ -60,13 +60,13 @@ bool two(T n)

template<typename T>
bool even(T n)
{
return n % T{2} == T{0};
return n % T {2} == T {0};
}
template<typename T>
bool odd(T n)
{
return n % T{2} != T{0};
return n % T {2} != T {0};
}
} // namespace based

diff --git a/include/based/list.hpp b/include/based/list.hpp

@@ -142,39 +142,39 @@ public:

using queue_t = std::pair<list_type, list_type>;
bool is_empty(const queue_t& que) const { return is_empty(que.first); }
bool is_empty(const queue_t& queue) const { return is_empty(queue.first); }
queue_t queue_empty() { return {node_empty(), node_empty()}; }
queue_t push_front(const queue_t& que, const value_type& val)
queue_t push_front(const queue_t& queue, const value_type& val)
{
auto new_node = allocate(val, que.first);
if (is_empty(que)) {
auto new_node = allocate(val, queue.first);
if (is_empty(queue)) {
return {new_node, new_node};
}
return {new_node, que.second};
return {new_node, queue.second};
}
queue_t push_back(const queue_t& que, const value_type& val)
queue_t push_back(const queue_t& queue, const value_type& val)
{
auto new_node = allocate(val, node_empty());
if (is_empty(que)) {
if (is_empty(queue)) {
return {new_node, new_node};
}
next(que.second) = new_node;
return {que.first, new_node};
next(queue.second) = new_node;
return {queue.first, new_node};
}
queue_t pop_front(const queue_t& que)
queue_t pop_front(const queue_t& queue)
{
if (is_empty(que)) {
return que;
if (is_empty(queue)) {
return queue;
}
queue_t ret = {next(que.first), que.second};
free(que.first);
queue_t ret = {next(queue.first), queue.second};
free(queue.first);
return ret;
}
void free(const queue_t& que) { free(que.first, que.second); }
void free(const queue_t& queue) { free(queue.first, queue.second); }
};
template<typename T, typename N>

diff --git a/include/based/type_traits.hpp b/include/based/type_traits.hpp

@@ -13,7 +13,7 @@ namespace based

template<typename T>
concept Integer = requires(T n) {
successor(n);
predecesor(n);
predecessor(n);
twice(n);
half(n);
positive(n);