Not finished, but no more time for improvements

This commit is contained in:
Christopher Sanden
2025-11-14 12:13:21 +01:00
parent 58772c0488
commit b8aa672431
3 changed files with 18 additions and 2 deletions

View File

@@ -101,6 +101,6 @@ typedef bool (*FSongRead)(
void ReadSongsFromFile(const std::string& aFilename, FSongRead aOnSongRead); void ReadSongsFromFile(const std::string& aFilename, FSongRead aOnSongRead);
void PrintList(TLinkedList* list);
#endif // SHARED_LIB_H #endif // SHARED_LIB_H

View File

@@ -1,4 +1,18 @@
#include <bits/stl_tree.h> #include <bits/stl_tree.h>
#include "SharedLib.h" #include "SharedLib.h"
int g_printIndex = 0;
static void PrintAccCallback(TBankAccount* acc, int /*i*/)
{
std::cout << g_printIndex++ << ": " << acc->ownerFirstName << " " << acc->ownerLastName
<< " | Balance: " << acc->getBalance() << std::endl;
}
void PrintList(TLinkedList* list)
{
if (!list)
return;
g_printIndex = 0;
list->forEach(PrintAccCallback);
}

View File

@@ -1,5 +1,6 @@
#include "main.h" #include "main.h"
#include "SharedLib.h" #include "SharedLib.h"
#include "Sort.h"
static TLinkedList g_list(false); static TLinkedList g_list(false);
@@ -7,7 +8,7 @@ static std::vector<TBankAccount*> g_array;
static bool onNameRead(const int idx, const int total, const std::string& first, const std::string& last) static bool onNameRead(const int idx, const int total, const std::string& first, const std::string& last)
{ {
auto* acc = new TBankAccount(EBankAccountType::Checking, first, last); auto* acc = new TBankAccount(Checking, first, last);
g_list.Append(acc); g_list.Append(acc);
g_array.push_back(acc); g_array.push_back(acc);
@@ -19,6 +20,7 @@ int main()
readNamesFromFile("random_names.txt", onNameRead); readNamesFromFile("random_names.txt", onNameRead);
Sort sorter(g_array.data(), (int)g_array.size(), &g_list); Sort sorter(g_array.data(), (int)g_array.size(), &g_list);
PrintList(&g_list);