Format source files
This commit is contained in:
8
makefile
8
makefile
@@ -4,7 +4,7 @@ CFLAGS = -std=c++17 -Wall -g -Wextra
|
||||
CPPS = $(wildcard test/*.cpp)
|
||||
EXES = $(patsubst %.cpp, %.out, $(CPPS))
|
||||
|
||||
.PHONY: all clean rebuild check
|
||||
.PHONY: all clean rebuild check format
|
||||
|
||||
all: $(EXES)
|
||||
|
||||
@@ -19,5 +19,11 @@ EXESQUOTED = $(patsubst %, "%", $(EXES))
|
||||
check: all
|
||||
./execute-all.sh
|
||||
|
||||
format:
|
||||
find src/ -name *.cpp -exec clang-format -i {} \;
|
||||
find src/ -name *.hpp -exec clang-format -i {} \;
|
||||
find test/ -name *.cpp -exec clang-format -i {} \;
|
||||
find test/ -name *.hpp -exec clang-format -i {} \;
|
||||
|
||||
%.out: %.cpp
|
||||
$(CC) $(CFLAGS) $< -o $@
|
||||
@@ -5,21 +5,15 @@
|
||||
namespace List
|
||||
{
|
||||
|
||||
template<class T>
|
||||
struct Node
|
||||
template<class T> struct Node
|
||||
{
|
||||
T value;
|
||||
std::unique_ptr<Node<T>> next;
|
||||
|
||||
Node(T const & _value)
|
||||
: value(_value),
|
||||
next(nullptr)
|
||||
{}
|
||||
Node(T const & _value) : value(_value), next(nullptr) { }
|
||||
};
|
||||
|
||||
template<class T>
|
||||
class List
|
||||
{
|
||||
template<class T> class List {
|
||||
private:
|
||||
std::unique_ptr<Node<T>> root;
|
||||
Node<T> * tailPtr;
|
||||
@@ -177,15 +171,8 @@ public:
|
||||
return currentNode->value;
|
||||
}
|
||||
|
||||
std::size_t GetSize() const
|
||||
{
|
||||
return size;
|
||||
}
|
||||
std::size_t GetSize() const { return size; }
|
||||
|
||||
List()
|
||||
: root(nullptr),
|
||||
tailPtr(nullptr),
|
||||
size(0)
|
||||
{}
|
||||
List() : root(nullptr), tailPtr(nullptr), size(0) { }
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
#pragma once
|
||||
#include "vector.hpp"
|
||||
|
||||
template<class T>
|
||||
class RingBuffer
|
||||
{
|
||||
template<class T> class RingBuffer {
|
||||
private:
|
||||
Vector<T> data;
|
||||
std::size_t head, tail;
|
||||
@@ -61,16 +59,7 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
bool IsEmpty() const
|
||||
{
|
||||
return head == tail;
|
||||
}
|
||||
bool IsEmpty() const { return head == tail; }
|
||||
|
||||
RingBuffer(std::size_t const size)
|
||||
: data(),
|
||||
head(0),
|
||||
tail(0)
|
||||
{
|
||||
data.Resize(size + 1ul);
|
||||
}
|
||||
RingBuffer(std::size_t const size) : data(), head(0), tail(0) { data.Resize(size + 1ul); }
|
||||
};
|
||||
@@ -1,9 +1,7 @@
|
||||
#pragma once
|
||||
#include "vector.hpp"
|
||||
|
||||
template<class T>
|
||||
class Stack
|
||||
{
|
||||
template<class T> class Stack {
|
||||
private:
|
||||
Vector<T> data;
|
||||
std::size_t actualSize;
|
||||
@@ -34,13 +32,7 @@ public:
|
||||
return retval;
|
||||
}
|
||||
|
||||
std::size_t GetSize() const
|
||||
{
|
||||
return actualSize;
|
||||
}
|
||||
std::size_t GetSize() const { return actualSize; }
|
||||
|
||||
Stack()
|
||||
: actualSize(0)
|
||||
{
|
||||
}
|
||||
Stack() : actualSize(0) { }
|
||||
};
|
||||
@@ -2,9 +2,7 @@
|
||||
#include <cstdlib>
|
||||
#include <stdexcept>
|
||||
|
||||
template<class T>
|
||||
class Vector
|
||||
{
|
||||
template<class T> class Vector {
|
||||
private:
|
||||
T * data;
|
||||
std::size_t reserveSize;
|
||||
@@ -68,19 +66,9 @@ public:
|
||||
return data[index];
|
||||
}
|
||||
|
||||
std::size_t GetSize() const
|
||||
{
|
||||
return size;
|
||||
}
|
||||
std::size_t GetSize() const { return size; }
|
||||
|
||||
std::size_t GetReserveSize() const
|
||||
{
|
||||
return reserveSize;
|
||||
}
|
||||
std::size_t GetReserveSize() const { return reserveSize; }
|
||||
|
||||
Vector()
|
||||
: data(nullptr),
|
||||
reserveSize(0ul),
|
||||
size(0ul)
|
||||
{}
|
||||
Vector() : data(nullptr), reserveSize(0ul), size(0ul) { }
|
||||
};
|
||||
@@ -3,35 +3,21 @@
|
||||
|
||||
namespace BinaryTree
|
||||
{
|
||||
template <class T>
|
||||
struct Node
|
||||
template<class T> struct Node
|
||||
{
|
||||
T value;
|
||||
|
||||
std::unique_ptr<Node<T>> left;
|
||||
std::unique_ptr<Node<T>> right;
|
||||
|
||||
bool HasChildren() const
|
||||
{
|
||||
return static_cast<bool>(left) || static_cast<bool>(right);
|
||||
}
|
||||
bool HasChildren() const { return static_cast<bool>(left) || static_cast<bool>(right); }
|
||||
|
||||
bool IsLeaf() const
|
||||
{
|
||||
return !HasChildren();
|
||||
}
|
||||
bool IsLeaf() const { return !HasChildren(); }
|
||||
|
||||
Node(T const &_value)
|
||||
: value(_value),
|
||||
left(nullptr),
|
||||
right(nullptr)
|
||||
{
|
||||
}
|
||||
Node(T const & _value) : value(_value), left(nullptr), right(nullptr) { }
|
||||
};
|
||||
|
||||
template <class T>
|
||||
class Tree
|
||||
{
|
||||
template<class T> class Tree {
|
||||
private:
|
||||
std::unique_ptr<Node<T>> root;
|
||||
|
||||
@@ -129,10 +115,7 @@ public:
|
||||
toInsertIn = std::make_unique<Node<T>>(value);
|
||||
}
|
||||
|
||||
bool Contains(T const & value)
|
||||
{
|
||||
return static_cast<bool>(FindNode(value));
|
||||
}
|
||||
bool Contains(T const & value) { return static_cast<bool>(FindNode(value)); }
|
||||
|
||||
void Delete(T const & value)
|
||||
{
|
||||
@@ -140,8 +123,6 @@ public:
|
||||
DeleteNode(node);
|
||||
}
|
||||
|
||||
Tree()
|
||||
: root(nullptr)
|
||||
{}
|
||||
Tree() : root(nullptr) { }
|
||||
};
|
||||
} // namespace BinaryTree
|
||||
@@ -1,9 +1,10 @@
|
||||
#include "../src/tree/binarytree.hpp"
|
||||
#include "testutil.hpp"
|
||||
#include <vector>
|
||||
#include <unordered_set>
|
||||
#include <vector>
|
||||
|
||||
void FillWithUniqueRandomNumbers(BinaryTree::Tree<unsigned> & tree,
|
||||
void FillWithUniqueRandomNumbers(
|
||||
BinaryTree::Tree<unsigned> & tree,
|
||||
std::unordered_set<unsigned> & control,
|
||||
unsigned const count = 10000u)
|
||||
{
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
#include "../src/sequential/vector.hpp"
|
||||
#include "testutil.hpp"
|
||||
|
||||
void FillWithSequentialNumbers(Vector<unsigned> & vector,
|
||||
unsigned const count = 1024u)
|
||||
void FillWithSequentialNumbers(Vector<unsigned> & vector, unsigned const count = 1024u)
|
||||
{
|
||||
for(unsigned i = 0; i < count; ++i)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user