Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ set(APP_SOURCES
"src/core/datatypes/container/adapter/Queue.cpp"
"src/core/datatypes/container/adapter/Stack.cpp"
"src/core/datatypes/container/sequence/Deque.cpp"
"src/core/datatypes/container/associative/Set.cpp"
## LC
"src/leetcode/arrays/two_sum/TwoSum.cpp"
"src/leetcode/arrays/median_two_arrays/MedianTwoSortedArrays.cpp"
Expand Down
1 change: 0 additions & 1 deletion src/controller/pid/PIDSim.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
#include "pid.h"

#include "ExampleRegistry.h"
#include "IExample.h"

namespace {
void run() {
Expand Down
1 change: 0 additions & 1 deletion src/core/basics/ControlFlow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ void exceptions() {
}

#include "ExampleRegistry.h"
#include "IExample.h"

class ControlFlow : public IExample {
public:
Expand Down
1 change: 0 additions & 1 deletion src/core/basics/InitializeVariable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using namespace std;

#include "ExampleRegistry.h"
#include "IExample.h"

void initialize_variable();

Expand Down
1 change: 0 additions & 1 deletion src/core/basics/Operations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using namespace std;

#include "ExampleRegistry.h"
#include "IExample.h"

void arithmeticOperator();
void logicalOperator();
Expand Down
1 change: 0 additions & 1 deletion src/core/basics/TypeQualifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ void run() {
} // namespace

#include "ExampleRegistry.h"
#include "IExample.h"

class TypeQualifier : public IExample {
public:
Expand Down
1 change: 0 additions & 1 deletion src/core/datatypes/CArray.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#include <iostream>

#include "ExampleRegistry.h"
#include "IExample.h"

void arrayExamples() {
std::cout << "\n--- Array Examples ---\n";
Expand Down
1 change: 0 additions & 1 deletion src/core/datatypes/CEnum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ void enums() {
}

#include "ExampleRegistry.h"
#include "IExample.h"

class CEnum : public IExample {
public:
Expand Down
1 change: 0 additions & 1 deletion src/core/datatypes/CPointers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ void pointers() {
}

#include "ExampleRegistry.h"
#include "IExample.h"

class CPointers : public IExample {
public:
Expand Down
1 change: 0 additions & 1 deletion src/core/datatypes/CReferences.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ void run() {
} // namespace RvalueReference

#include "ExampleRegistry.h"
#include "IExample.h"

class CReferences : public IExample {
public:
Expand Down
1 change: 0 additions & 1 deletion src/core/datatypes/CStruct.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ void structs() {
}

#include "ExampleRegistry.h"
#include "IExample.h"

class CStruct : public IExample {
public:
Expand Down
1 change: 0 additions & 1 deletion src/core/datatypes/CUnion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ void unionDemo() {

// --- Auto-run struct ---
#include "ExampleRegistry.h"
#include "IExample.h"

class CUnion : public IExample {
public:
Expand Down
1 change: 0 additions & 1 deletion src/core/datatypes/Fundamental.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ void primative() {
}

#include "ExampleRegistry.h"
#include "IExample.h"

class Fundamental : public IExample {
public:
Expand Down
1 change: 0 additions & 1 deletion src/core/datatypes/TypeConVersions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,6 @@ void typeDeduction() {
}

#include "ExampleRegistry.h"
#include "IExample.h"

class CTypeConversion : public IExample {
public:
Expand Down
1 change: 0 additions & 1 deletion src/core/datatypes/class/CConstructors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,6 @@ void constructers() {
} // namespace Move

#include "ExampleRegistry.h"
#include "IExample.h"

class CConstructors : public IExample {
public:
Expand Down
1 change: 0 additions & 1 deletion src/core/datatypes/class/CDestructors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ void destructers() {
} // namespace Virtual

#include "ExampleRegistry.h"
#include "IExample.h"

class CDestructors : public IExample {
public:
Expand Down
1 change: 0 additions & 1 deletion src/core/datatypes/class/RoleOfThreeFiveZero.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,6 @@ void run() {
} // namespace

#include "ExampleRegistry.h"
#include "IExample.h"

class RoleOfThreeFiveZero : public IExample {
public:
Expand Down
1 change: 0 additions & 1 deletion src/core/datatypes/class/SallowDeepCopying.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@ void run() {
} // namespace

#include "ExampleRegistry.h"
#include "IExample.h"

class ShallowDeepCopying : public IExample {
public:
Expand Down
26 changes: 21 additions & 5 deletions src/core/datatypes/container/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
- The Containers library is a generic collection of class templates and algorithms that allow programmers to easilly implement common data structures.
- All container functions can be called concurrently by different threads on different containers
## 1. Sequence Containers
Sequence containers implement data structures which can be accessed sequentially.
*Sequence containers* implement data structures which can be accessed sequentially.

|name|description|
|---|---|
Expand All @@ -12,18 +12,34 @@ Sequence containers implement data structures which can be accessed sequentially
|forward_list|singly-linked list|
|list|doubly-linked list|

<br>

## 2. Unordered Containers
Unordered associative containers implement unsorted (hashed) data structures that can be quickly searched (O(1) average, O(n) worst-case complexity).
*Unordered associative containers* implement unsorted (hashed) data structures that can be quickly searched (**O(1) average, O(n) worst-case complexity**).

|name|description|
|---|---|
|unordered_map|collection of key-value pairs, hashed by keys, keys are unique|
|unordered_set|collection of unique keys, hashed by keys|

## 3. Adapter Container
**Container adaptors** provide a different interface for **sequential containers**.
<br>

## 3. Adapter Containers
*Container adaptors* provide a different interface for **sequential containers**.

|name|description|
|---|---|
|queue|apdapts a container to provide queue (**FIFO** data structure)|
|stack|adapts a container to provide stack (**LIFO** data structure)|

TBD
<br>

## 4. Associative Containers
- *Associative containers* implement sorted data structures that can be quickly searched (**O(logn)**)

|name|description|
|---|---|
|set|collection of unique keys, sorted by keys|
|map|collection of key-value pairs, sorted by keys|

<br>
5 changes: 2 additions & 3 deletions src/core/datatypes/container/adapter/Queue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,13 @@ void run() {
} // namespace

#include "ExampleRegistry.h"
#include "IExample.h"

class Queue : public IExample {
public:
std::string group() const override { return "core"; }
std::string group() const override { return "core/container"; }
std::string name() const override { return "Queue"; }
std::string description() const override { return "std::queue Example"; }
void execute() override { run(); }
};

REGISTER_EXAMPLE(Queue, "core", "Queue");
REGISTER_EXAMPLE(Queue, "core/container", "Queue");
4 changes: 2 additions & 2 deletions src/core/datatypes/container/adapter/Stack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ void run() {

class Stack : public IExample {
public:
std::string group() const override { return "core"; }
std::string group() const override { return "core/container"; }
std::string name() const override { return "Stack"; }
std::string description() const override { return "std::stack Example"; }
void execute() override { run(); }
};

REGISTER_EXAMPLE(Stack, "core", "Stack");
REGISTER_EXAMPLE(Stack, "core/container", "Stack");
33 changes: 33 additions & 0 deletions src/core/datatypes/container/associative/Set.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@

// cppcheck-suppress-file []
#include <iostream>
#include <set>
#include "ExampleRegistry.h"

namespace {
void run() {
// 1. Init
std::set<int> m_set{3, 4, 5, 1, 2};

// 2. Modifiers
m_set.insert(-1);

m_set.insert(99);
m_set.erase(99);

for (const auto k : m_set) {
std::cout << k << " ";
}
std::cout << std::endl;
}
} // namespace

class Set : public IExample {
public:
std::string group() const override { return "core/container"; }
std::string name() const override { return "Set"; }
std::string description() const override { return "std::set Example"; }
void execute() override { run(); }
};

REGISTER_EXAMPLE(Set, "core/container", "Set");
5 changes: 2 additions & 3 deletions src/core/datatypes/container/sequence/Array.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,13 @@ void run() {
} // namespace

#include "ExampleRegistry.h"
#include "IExample.h"

class Array : public IExample {
public:
std::string group() const override { return "core"; }
std::string group() const override { return "core/container"; }
std::string name() const override { return "Array"; }
std::string description() const override { return ""; }
void execute() override { run(); }
};

REGISTER_EXAMPLE(Array, "core", "Array");
REGISTER_EXAMPLE(Array, "core/container", "Array");
5 changes: 2 additions & 3 deletions src/core/datatypes/container/sequence/Deque.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,13 @@ void run() {
} // namespace

#include "ExampleRegistry.h"
#include "IExample.h"

class Deque : public IExample {
public:
std::string group() const override { return "core"; }
std::string group() const override { return "core/container"; }
std::string name() const override { return "Deque"; }
std::string description() const override { return "std::deque Example"; }
void execute() override { run(); }
};

REGISTER_EXAMPLE(Deque, "core", "Deque");
REGISTER_EXAMPLE(Deque, "core/container", "Deque");
5 changes: 2 additions & 3 deletions src/core/datatypes/container/sequence/Vector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,13 @@ void run() {
} // namespace

#include "ExampleRegistry.h"
#include "IExample.h"

class Vector : public IExample {
public:
std::string group() const override { return "core"; }
std::string group() const override { return "core/container"; }
std::string name() const override { return "Vector"; }
std::string description() const override { return ""; }
void execute() override { run(); }
};

REGISTER_EXAMPLE(Vector, "core", "Vector");
REGISTER_EXAMPLE(Vector, "core/container", "Vector");
5 changes: 2 additions & 3 deletions src/core/datatypes/container/unordered/UnorderedMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,13 @@ void run() {
} // namespace

#include "ExampleRegistry.h"
#include "IExample.h"

class UnorderedMap : public IExample {
public:
std::string group() const override { return "core"; }
std::string group() const override { return "core/container"; }
std::string name() const override { return "UnorderedMap"; }
std::string description() const override { return ""; }
void execute() override { run(); }
};

REGISTER_EXAMPLE(UnorderedMap, "core", "UnorderedMap");
REGISTER_EXAMPLE(UnorderedMap, "core/container", "UnorderedMap");
1 change: 0 additions & 1 deletion src/core/datatypes/smart_pointer/Shared.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ void run() {
} // namespace

#include "ExampleRegistry.h"
#include "IExample.h"

class Shared : public IExample {
public:
Expand Down
1 change: 0 additions & 1 deletion src/core/datatypes/smart_pointer/Unique.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ void run() {
} // namespace

#include "ExampleRegistry.h"
#include "IExample.h"

class Unique : public IExample {
public:
Expand Down
1 change: 0 additions & 1 deletion src/core/datatypes/smart_pointer/Weak.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ void run() {
* wp.lock() != nullptr // same condition
*/
#include "ExampleRegistry.h"
#include "IExample.h"

class Weak : public IExample {
public:
Expand Down
5 changes: 2 additions & 3 deletions src/core/exception/BasicHandle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,15 @@ void run() {
} // namespace

#include "ExampleRegistry.h"
#include "IExample.h"

class BasicHandle : public IExample {
public:
std::string group() const override { return "core"; }
std::string group() const override { return "core/exception"; }
std::string name() const override { return "BasicHandle"; }
std::string description() const override {
return "Basic Expception Handle Example";
}
void execute() override { run(); }
};

REGISTER_EXAMPLE(BasicHandle, "core", "BasicHandle");
REGISTER_EXAMPLE(BasicHandle, "core/exception", "BasicHandle");
Loading