diff --git a/CMakeLists.txt b/CMakeLists.txt index 5be2f98..6ab4d6f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ ## Please modify this file freely to adapt to the production of other -## executables than convexhull and testrun +## executables than upperhull and testrun # Description of the different builds # +---------------+--------------+--------------+----------| @@ -87,18 +87,18 @@ get_property(inc_dirs DIRECTORY PROPERTY INCLUDE_DIRECTORIES) message("inc_dirs = ${inc_dirs}") # Convex Hulls : 8, 16, 32 or 64 bits and the version with extras -file(GLOB SOURCES "examples/convexhull/convexHull8.cpp") -add_executable(convexhull8 ${SOURCES}) -file(GLOB SOURCES "examples/convexhull/convexHull16.cpp") -add_executable(convexhull16 ${SOURCES}) -file(GLOB SOURCES "examples/convexhull/convexHull32.cpp") -add_executable(convexhull32 ${SOURCES}) -file(GLOB SOURCES "examples/convexhull/convexHull64.cpp") -add_executable(convexhull64 ${SOURCES}) -file(GLOB SOURCES "examples/convexhull/convexHullExtras.cpp") -add_executable(convexhullextras ${SOURCES}) -file(GLOB SOURCES "examples/convexhull/generateInputConvexHull.cpp") -add_executable(generateInputConvexHull ${SOURCES}) +file(GLOB SOURCES "examples/upperhull/upperHull8.cpp") +add_executable(upperhull8 ${SOURCES}) +file(GLOB SOURCES "examples/upperhull/upperHull16.cpp") +add_executable(upperhull16 ${SOURCES}) +file(GLOB SOURCES "examples/upperhull/upperHull32.cpp") +add_executable(upperhull32 ${SOURCES}) +file(GLOB SOURCES "examples/upperhull/upperHull64.cpp") +add_executable(upperhull64 ${SOURCES}) +file(GLOB SOURCES "examples/upperhull/upperHullExtras.cpp") +add_executable(upperhullextras ${SOURCES}) +file(GLOB SOURCES "examples/upperhull/generateInputUpperHull.cpp") +add_executable(generateInputUpperHull ${SOURCES}) # Test Run : 8, 16, 32 or 64 bits and the version with extras diff --git a/README.md b/README.md index c5b58b4..59985e8 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ template void StackAlgo::run() { } ``` ## Use case -Concrete examples such as a basic test run and the convex hull problem can be found in the [wiki](https://github.com/Azzaare/CompressedStacks.cpp/wiki). +Concrete examples such as a basic test run and the upper hull problems can be found in the [wiki](https://github.com/Azzaare/CompressedStacks.cpp/wiki). ### Abstract example : ```Instance```

An instance of a Stack Algorithm is described by a set of templates parameters T, D, and I and a set of methods used in the run function above.

diff --git a/examples/convexhull/generateInputConvexHull.cpp b/examples/upperhull/generateInputUpperHull.cpp similarity index 97% rename from examples/convexhull/generateInputConvexHull.cpp rename to examples/upperhull/generateInputUpperHull.cpp index cf23c7a..3b24a8c 100644 --- a/examples/convexhull/generateInputConvexHull.cpp +++ b/examples/upperhull/generateInputUpperHull.cpp @@ -44,7 +44,7 @@ int main(int argc, char *argv[]) { std::uint_least64_t i = 0; while (i < n) { - // create output for the convex hull problem. + // create output for the upper hull problem. // in this case, max and min stand for the maximum and minimum values of x // and y // generate a random point in the (min,max)2 range diff --git a/examples/convexhull/include/point2D.hpp b/examples/upperhull/include/point2D.hpp similarity index 100% rename from examples/convexhull/include/point2D.hpp rename to examples/upperhull/include/point2D.hpp diff --git a/examples/convexhull/include/convexHull.hpp b/examples/upperhull/include/upperHull.hpp similarity index 78% rename from examples/convexhull/include/convexHull.hpp rename to examples/upperhull/include/upperHull.hpp index 90fbf2c..608d672 100644 --- a/examples/convexhull/include/convexHull.hpp +++ b/examples/upperhull/include/upperHull.hpp @@ -1,6 +1,6 @@ -// ConvexHull : Definition -#ifndef CONVEXHULL -#define CONVEXHULL +// UpperHull : Definition +#ifndef UPPERHULL +#define UPPERHULL /*============================================================================== Includes @@ -20,9 +20,9 @@ class emptyContext {}; Instantiation of a problem ==============================================================================*/ template -class ConvexHull : public StackAlgo { +class UpperHull : public StackAlgo { public: - ConvexHull(std::string filePath) + UpperHull(std::string filePath) : StackAlgo(filePath) {} private: @@ -58,7 +58,7 @@ class ConvexHull : public StackAlgo { * reportStack ==============================================================================*/ template -Point2D ConvexHull::readInput(std::vector line) { +Point2D UpperHull::readInput(std::vector line) { double x = std::stof(line[0]); double y = std::stof(line[1]); @@ -68,7 +68,7 @@ Point2D ConvexHull::readInput(std::vector line) { return p; } -template std::shared_ptr ConvexHull::initStack() { +template std::shared_ptr UpperHull::initStack() { std::cout << "going to read two values " << std::endl; @@ -82,7 +82,7 @@ template std::shared_ptr ConvexHull::initStack() { return context; } -template bool ConvexHull::popCondition(Point2D last) { +template bool UpperHull::popCondition(Point2D last) { Point2D minus1, minus2; total++; std::cout << std::endl << last << " <<<< pop condition enter " << std::endl; @@ -114,26 +114,26 @@ template bool ConvexHull::popCondition(Point2D last) { return false; } -template void ConvexHull::prePop(Point2D data) {} +template void UpperHull::prePop(Point2D data) {} template -void ConvexHull::postPop(Point2D data, Data elt) { +void UpperHull::postPop(Point2D data, Data elt) { std::cout << elt.getData() << " <<<< (post-)Pop!" << std::endl; } -template void ConvexHull::noPop(Point2D data) {} +template void UpperHull::noPop(Point2D data) {} -template bool ConvexHull::pushCondition(Point2D data) { +template bool UpperHull::pushCondition(Point2D data) { std::cout << data << " <<<< push condition returning true " << std::endl; return true; } template -void ConvexHull::prePush(Data elt) {} +void UpperHull::prePush(Data elt) {} template -void ConvexHull::postPush(Data elt) { - std::cout << "ConvexHullStackAlgo::pushAction Nothing to see here " +void UpperHull::postPush(Data elt) { + std::cout << "UpperHullStackAlgo::pushAction Nothing to see here " << elt.getData() << std::endl; } -template void ConvexHull::noPush(Point2D data) {} +template void UpperHull::noPush(Point2D data) {} -template void ConvexHull::reportStack() {} +template void UpperHull::reportStack() {} -#endif // CONVEXHULL +#endif // UPPERHULL diff --git a/examples/convexhull/include/convexHullExtras.hpp b/examples/upperhull/include/upperHullExtras.hpp similarity index 74% rename from examples/convexhull/include/convexHullExtras.hpp rename to examples/upperhull/include/upperHullExtras.hpp index 01c7966..1de1233 100644 --- a/examples/convexhull/include/convexHullExtras.hpp +++ b/examples/upperhull/include/upperHullExtras.hpp @@ -1,6 +1,6 @@ -// ConvexHull : Definition -#ifndef CONVEXHULLEXTRAS -#define CONVEXHULLEXTRAS +// UpperHull : Definition +#ifndef UPPERHULLEXTRAS +#define UPPERHULLEXTRAS /*============================================================================== Includes @@ -18,9 +18,9 @@ class emptyContext {}; ==============================================================================*/ template -class ConvexHullExtras : public StackAlgoExtras { +class UpperHullExtras : public StackAlgoExtras { public: - ConvexHullExtras(std::string filePath, bool usecompressed, bool useclassic) + UpperHullExtras(std::string filePath, bool usecompressed, bool useclassic) : StackAlgoExtras(filePath, usecompressed, useclassic) {} @@ -57,7 +57,7 @@ class ConvexHullExtras : public StackAlgoExtras { * reportStack ==============================================================================*/ template -Point2D ConvexHullExtras::readInput(std::vector line) { +Point2D UpperHullExtras::readInput(std::vector line) { double x = std::stof(line[0]); double y = std::stof(line[1]); @@ -69,7 +69,7 @@ Point2D ConvexHullExtras::readInput(std::vector line) { } template -std::shared_ptr ConvexHullExtras::initStack() { +std::shared_ptr UpperHullExtras::initStack() { // std::cout << "going to read two values " << std::endl; // first, read and push two values @@ -85,7 +85,7 @@ std::shared_ptr ConvexHullExtras::initStack() { return context; } -template bool ConvexHullExtras::popCondition(Point2D last) { +template bool UpperHullExtras::popCondition(Point2D last) { Point2D minus1, minus2; std::cout << std::endl << last << " <<<< pop condition enter " << std::endl; StackAlgo::println(); @@ -103,27 +103,27 @@ template bool ConvexHullExtras::popCondition(Point2D last) { return false; } -template void ConvexHullExtras::prePop(Point2D data) {} +template void UpperHullExtras::prePop(Point2D data) {} template -void ConvexHullExtras::postPop(Point2D data, - Data elt) { +void UpperHullExtras::postPop(Point2D data, + Data elt) { // std::cout << elt.getData() << " <<<< Pop!" << std::endl; } -template void ConvexHullExtras::noPop(Point2D data) {} +template void UpperHullExtras::noPop(Point2D data) {} -template bool ConvexHullExtras::pushCondition(Point2D data) { +template bool UpperHullExtras::pushCondition(Point2D data) { // std::cout << data << " <<<< push condition returning true " << std::endl; return true; } template -void ConvexHullExtras::prePush(Data elt) {} +void UpperHullExtras::prePush(Data elt) {} template -void ConvexHullExtras::postPush(Data elt) { - // std::cout << "ConvexHullStackAlgo::pushAction Nothing to see here " << +void UpperHullExtras::postPush(Data elt) { + // std::cout << "UpperHullStackAlgo::pushAction Nothing to see here " << // elt.getData() << std::endl; } -template void ConvexHullExtras::noPush(Point2D data) {} +template void UpperHullExtras::noPush(Point2D data) {} -template void ConvexHullExtras::reportStack() {} +template void UpperHullExtras::reportStack() {} -#endif // CONVEXHULLEXTRAS +#endif // UPPERHULLEXTRAS diff --git a/examples/convexhull/instances/testFileConvexHull1000p50.txt b/examples/upperhull/instances/testFileUpperHull1000p50.txt similarity index 100% rename from examples/convexhull/instances/testFileConvexHull1000p50.txt rename to examples/upperhull/instances/testFileUpperHull1000p50.txt diff --git a/examples/convexhull/convexHull32.cpp b/examples/upperhull/upperHull16.cpp similarity index 71% rename from examples/convexhull/convexHull32.cpp rename to examples/upperhull/upperHull16.cpp index fd59c98..16ea05d 100644 --- a/examples/convexhull/convexHull32.cpp +++ b/examples/upperhull/upperHull16.cpp @@ -1,19 +1,19 @@ -// ConvexHull : Implementation +// UpperHull : Implementation /*============================================================================== Includes ==============================================================================*/ -#include "include/convexHull.hpp" +#include "include/upperHull.hpp" #include /*============================================================================== Type alias for the different integer size (based on the size of the input) ==============================================================================*/ -// using ConvexHull8 = ConvexHull; -// using ConvexHull16 = ConvexHull; -using ConvexHull32 = ConvexHull; -// using ConvexHull64 = ConvexHull; +// using UpperHull8 = UpperHull; +using UpperHull16 = UpperHull; +// using UpperHull32 = UpperHull; +// using UpperHull64 = UpperHull; /*============================================================================== How to use @@ -23,7 +23,7 @@ int main(int argc, char *argv[]) { // Getting the path of the instance to test std::string filepath = argv[1]; - ConvexHull32 stack(filepath); + UpperHull16 stack(filepath); stack.run(); // stack.println(); diff --git a/examples/convexhull/convexHull8.cpp b/examples/upperhull/upperHull32.cpp similarity index 69% rename from examples/convexhull/convexHull8.cpp rename to examples/upperhull/upperHull32.cpp index 409d1f6..68bf09f 100644 --- a/examples/convexhull/convexHull8.cpp +++ b/examples/upperhull/upperHull32.cpp @@ -1,19 +1,19 @@ -// ConvexHull : Implementation +// UpperHull : Implementation /*============================================================================== Includes ==============================================================================*/ -#include "include/convexHull.hpp" +#include "include/upperHull.hpp" #include /*============================================================================== Type alias for the different integer size (based on the size of the input) ==============================================================================*/ -using ConvexHull8 = ConvexHull; -// using ConvexHull16 = ConvexHull; -// using ConvexHull32 = ConvexHull; -// using ConvexHull64 = ConvexHull; +// using UpperHull8 = UpperHull; +// using UpperHull16 = UpperHull; +using UpperHull32 = UpperHull; +// using UpperHull64 = UpperHull; /*============================================================================== How to use @@ -23,9 +23,9 @@ int main(int argc, char *argv[]) { // Getting the path of the instance to test std::string filepath = argv[1]; - ConvexHull8 stack(filepath); + UpperHull32 stack(filepath); stack.run(); - //stack.println(); + // stack.println(); return 0; } diff --git a/examples/convexhull/convexHull16.cpp b/examples/upperhull/upperHull64.cpp similarity index 69% rename from examples/convexhull/convexHull16.cpp rename to examples/upperhull/upperHull64.cpp index 2a711c4..650a528 100644 --- a/examples/convexhull/convexHull16.cpp +++ b/examples/upperhull/upperHull64.cpp @@ -1,19 +1,19 @@ -// ConvexHull : Implementation +// UpperHull : Implementation /*============================================================================== Includes ==============================================================================*/ -#include "include/convexHull.hpp" +#include "include/upperHull.hpp" #include /*============================================================================== Type alias for the different integer size (based on the size of the input) ==============================================================================*/ -// using ConvexHull8 = ConvexHull; -using ConvexHull16 = ConvexHull; -// using ConvexHull32 = ConvexHull; -// using ConvexHull64 = ConvexHull; +// using UpperHull8 = UpperHull; +// using UpperHull16 = UpperHull; +// using UpperHull32 = UpperHull; +using UpperHull64 = UpperHull; /*============================================================================== How to use @@ -23,9 +23,9 @@ int main(int argc, char *argv[]) { // Getting the path of the instance to test std::string filepath = argv[1]; - ConvexHull16 stack(filepath); + UpperHull64 stack(filepath); stack.run(); - //stack.println(); + // stack.println(); return 0; } diff --git a/examples/convexhull/convexHull64.cpp b/examples/upperhull/upperHull8.cpp similarity index 69% rename from examples/convexhull/convexHull64.cpp rename to examples/upperhull/upperHull8.cpp index b61126f..5f35510 100644 --- a/examples/convexhull/convexHull64.cpp +++ b/examples/upperhull/upperHull8.cpp @@ -1,19 +1,19 @@ -// ConvexHull : Implementation +// UpperHull : Implementation /*============================================================================== Includes ==============================================================================*/ -#include "include/convexHull.hpp" +#include "include/upperHull.hpp" #include /*============================================================================== Type alias for the different integer size (based on the size of the input) ==============================================================================*/ -// using ConvexHull8 = ConvexHull; -// using ConvexHull16 = ConvexHull; -// using ConvexHull32 = ConvexHull; -using ConvexHull64 = ConvexHull; +using UpperHull8 = UpperHull; +// using UpperHull16 = UpperHull; +// using UpperHull32 = UpperHull; +// using UpperHull64 = UpperHull; /*============================================================================== How to use @@ -23,9 +23,9 @@ int main(int argc, char *argv[]) { // Getting the path of the instance to test std::string filepath = argv[1]; - ConvexHull64 stack(filepath); + UpperHull8 stack(filepath); stack.run(); - //stack.println(); + // stack.println(); return 0; } diff --git a/examples/convexhull/convexHullExtras.cpp b/examples/upperhull/upperHullExtras.cpp similarity index 77% rename from examples/convexhull/convexHullExtras.cpp rename to examples/upperhull/upperHullExtras.cpp index 042772c..4fc342c 100644 --- a/examples/convexhull/convexHullExtras.cpp +++ b/examples/upperhull/upperHullExtras.cpp @@ -1,19 +1,19 @@ -// ConvexHull : Implementation +// UpperHull : Implementation /*============================================================================== Includes ==============================================================================*/ -#include "include/convexHullExtras.hpp" +#include "include/upperHullExtras.hpp" #include /*============================================================================== Type alias for the different integer size (based on the size of the input) ==============================================================================*/ -using ConvexHullExtras8 = ConvexHullExtras; -using ConvexHullExtras16 = ConvexHullExtras; -using ConvexHullExtras32 = ConvexHullExtras; -using ConvexHullExtras64 = ConvexHullExtras; +using UpperHullExtras8 = UpperHullExtras; +using UpperHullExtras16 = UpperHullExtras; +using UpperHullExtras32 = UpperHullExtras; +using UpperHullExtras64 = UpperHullExtras; /*============================================================================== How to use @@ -56,46 +56,46 @@ int main(int argc, char *argv[]) { switch (atoi(argv[3])) { case 8: { - ConvexHullExtras8 stack(filepath, usecompressed, useclassic); + UpperHullExtras8 stack(filepath, usecompressed, useclassic); if (usecompressed && useclassic) { stack.runCompare(); stack.printCompare(); } else { stack.run(); - //stack.println(); + // stack.println(); } break; } case 16: { - ConvexHullExtras16 stack(filepath, usecompressed, useclassic); + UpperHullExtras16 stack(filepath, usecompressed, useclassic); if (usecompressed && useclassic) { stack.runCompare(); stack.printCompare(); } else { stack.run(); - //stack.println(); + // stack.println(); } break; } case 32: { - ConvexHullExtras32 stack(filepath, usecompressed, useclassic); + UpperHullExtras32 stack(filepath, usecompressed, useclassic); if (usecompressed && useclassic) { stack.runCompare(); stack.printCompare(); } else { stack.run(); - //stack.println(); + // stack.println(); } break; } default: - ConvexHullExtras64 stack(filepath, usecompressed, useclassic); + UpperHullExtras64 stack(filepath, usecompressed, useclassic); if (usecompressed && useclassic) { stack.runCompare(); stack.printCompare(); } else { stack.run(); - //stack.println(); + // stack.println(); } } diff --git a/include/compressedStack.hpp b/include/compressedStack.hpp index df73004..a86adce 100644 --- a/include/compressedStack.hpp +++ b/include/compressedStack.hpp @@ -82,6 +82,7 @@ class CompressedStack : public Stack { /* Push related */ void pushExplicit(SPData elt); void pushCompressed(SPData elt, std::intmax_t lvl, I headIndex); + // TODO: Check if compress is used void compress(Level block); void resetLevel(Block block, std::intmax_t lvl); @@ -771,6 +772,7 @@ void CompressedStack::popBuffer() { } } +// TODO: erase problem from signature template SPData CompressedStack::popExplicit(StackAlgo &problem,