save
This commit is contained in:
parent
3afe24c9a8
commit
96e6514337
5 changed files with 23 additions and 33 deletions
|
@ -100,7 +100,7 @@ FetchContent_Declare(
|
|||
|
||||
FetchContent_MakeAvailable(lua)
|
||||
|
||||
set(LUA_BUILD_INTERPRETER ON)
|
||||
set(LUA_BUILD_INTERPRETER ON CACHE BOOL "Build the Lua interpreter" FORCE)
|
||||
|
||||
# ========================================================
|
||||
# Helper Function: Set Common Target Properties
|
||||
|
|
|
@ -5,6 +5,9 @@
|
|||
#include <mutex>
|
||||
#include <utility>
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
/**
|
||||
* @brief A thread-safe dynamic array container class
|
||||
*
|
||||
|
@ -160,6 +163,22 @@ public:
|
|||
return size_;
|
||||
}
|
||||
|
||||
friend std::ostream& operator<<(std::ostream& os, const List& list)
|
||||
{
|
||||
os << "[List] List( type: {" << typeid(T).name() << "}, size: " << list.size_ << ") [ ";
|
||||
for (size_t i = 0; i < list.size_ - 1; i++)
|
||||
{
|
||||
os << list[i] << ", ";
|
||||
}
|
||||
os << list[list.size_ - 1] << " ]";
|
||||
return os;
|
||||
}
|
||||
|
||||
static std::string type_name()
|
||||
{
|
||||
return "List<" + std::string(typeid(T).name()) + ">";
|
||||
}
|
||||
|
||||
private:
|
||||
std::unique_ptr<T[]> data_; ///< Underlying array storage
|
||||
std::size_t size_; ///< Number of elements in the array
|
||||
|
|
|
@ -39,16 +39,9 @@ void SortingTester::load_internal()
|
|||
|
||||
void SortingTester::populate(const populate_function& f)
|
||||
{
|
||||
std::cout << "[List(" << list.size() << ")] [ ";
|
||||
for (size_t i = 0; i < list.size(); i++)
|
||||
{
|
||||
f(i, list[i]);
|
||||
if(i == list.size()-1)
|
||||
{
|
||||
std::cout << list[i] << " ]\n";
|
||||
break;
|
||||
}
|
||||
std::cout << list[i] << ", ";
|
||||
}
|
||||
std::flush(std::cout);
|
||||
std::cout << list << std::endl;
|
||||
}
|
||||
|
|
|
@ -126,32 +126,11 @@ public:
|
|||
if (!is_sorted())
|
||||
{
|
||||
std::cerr << "[ERROR] The algorithm \"" << function_name << "\" did not sort the list" << std::endl;
|
||||
std::cerr << "[List] [ ";
|
||||
for (size_t i = 0; i < list.size(); i++)
|
||||
{
|
||||
if(i == list.size()-1)
|
||||
{
|
||||
std::cerr << list[i] << " ]";
|
||||
continue;
|
||||
}
|
||||
std::cerr << list[i] << ", ";
|
||||
}
|
||||
std::cerr << list << std::endl;
|
||||
std::flush(std::cerr);
|
||||
std::terminate();
|
||||
}
|
||||
|
||||
std::cout << "[sorted: List(" << list.size() << ")] [ ";
|
||||
for (size_t i = 0; i < list.size(); i++)
|
||||
{
|
||||
if(i == list.size()-1)
|
||||
{
|
||||
std::cout << list[i] << " ]\n";
|
||||
break;
|
||||
}
|
||||
std::cout << list[i] << ", ";
|
||||
}
|
||||
std::flush(std::cout);
|
||||
|
||||
result.count_comparisons = result.count_equal + result.count_greater + result.count_less;
|
||||
|
||||
active_result = nullptr;
|
||||
|
|
|
@ -82,8 +82,7 @@ int main(int argc, char** argv)
|
|||
|
||||
|
||||
std::cout << "\nPress any key to exit..." << std::endl;
|
||||
getchar();
|
||||
return 0;
|
||||
// getchar();
|
||||
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Reference in a new issue