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
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ target_include_directories(mlcpppy PUBLIC ${PROJECT_SOURCE_DIR}/include)
# -------------------------------
add_executable(example_main examples/main.cpp)
add_executable(example_instance examples/atributes_usage.cpp)
add_executable(example_binary_tree examples/example_binary_tree.cpp)

# Linka a biblioteca ao executável
target_link_libraries(example_main PRIVATE mlcpppy)
target_link_libraries(example_instance PRIVATE mlcpppy)
target_link_libraries(example_binary_tree PRIVATE mlcpppy)
18 changes: 9 additions & 9 deletions examples/atributes_usage.cpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#include <iostream>

#include "mlcpppy/instances/instances.h"

int main(int argc, char const *argv[])
{
// Exemplo de uso da classe atribute, instances e instance
Instance a(Attribute(1), Attribute(2.5), Attribute("Pedro"));
Instance b(Attribute(1), Attribute(2.5), Attribute("Pedro"));
Instance c(Attribute(1), Attribute(2.5), Attribute("Pedro"));
Instances matrix({a,b,c});
std::cout << matrix << std::endl;
return 0;
int main(int argc, char const *argv[]) {
// Exemplo de uso da classe atribute, instances e instance
Instance a(Attribute(1), Attribute(2.5), Attribute("Pedro"));
Instance b(Attribute(1), Attribute(2.5), Attribute("Pedro"));
Instance c(Attribute(1), Attribute(2.5), Attribute("Pedro"));
Instances matrix({a, b, c});
std::cout << matrix << std::endl;
return 0;
}
28 changes: 28 additions & 0 deletions examples/example_binary_tree.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#include "mlcpppy/data_structures/binary_tree.h"

int main(int argc, char const* argv[]) {
BinaryTree<int>* binary_tree = new BinaryTree<int>();
// Isso deixa desbalanceado
// 20, 8, 22, 4, 12, 10, 14

binary_tree->Insert(20);
binary_tree->Insert(8);
binary_tree->Insert(22);
binary_tree->Insert(4);
binary_tree->Insert(12);
binary_tree->Insert(10);
binary_tree->Insert(14);

binary_tree->TreeSuccessor();

binary_tree->Inorder();

BinaryTree<int>::Node* busca = binary_tree->Search(8);
if (busca) {
binary_tree->Delete(busca);
}

binary_tree->Inorder();

return 0;
}
Loading