Finished
This commit is contained in:
54
assignment1/.idea/workspace.xml
generated
54
assignment1/.idea/workspace.xml
generated
@@ -30,13 +30,11 @@
|
|||||||
</component>
|
</component>
|
||||||
<component name="ChangeListManager">
|
<component name="ChangeListManager">
|
||||||
<list default="true" id="e3758ede-1321-4b2e-94dd-da87753a03f6" name="Changes" comment="">
|
<list default="true" id="e3758ede-1321-4b2e-94dd-da87753a03f6" name="Changes" comment="">
|
||||||
<change beforePath="$PROJECT_DIR$/.idea/editor.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/editor.xml" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/TMovie.h" beforeDir="false" afterPath="$PROJECT_DIR$/TMovie.h" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/TMovie.h" beforeDir="false" afterPath="$PROJECT_DIR$/TMovie.h" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/TMovieList.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/TMovieList.cpp" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/TMovieList.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/TMovieList.cpp" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/TMovieList.h" beforeDir="false" afterPath="$PROJECT_DIR$/TMovieList.h" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/TMovieList.h" beforeDir="false" afterPath="$PROJECT_DIR$/TMovieList.h" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/TMovieNode.h" beforeDir="false" afterPath="$PROJECT_DIR$/TMovieNode.h" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/main.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/main.cpp" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/cmake-build-debug/Testing/Temporary/LastTest.log" beforeDir="false" afterPath="$PROJECT_DIR$/cmake-build-debug/Testing/Temporary/LastTest.log" afterDir="false" />
|
|
||||||
</list>
|
</list>
|
||||||
<option name="SHOW_DIALOG" value="false" />
|
<option name="SHOW_DIALOG" value="false" />
|
||||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||||
@@ -64,31 +62,31 @@
|
|||||||
<option name="hideEmptyMiddlePackages" value="true" />
|
<option name="hideEmptyMiddlePackages" value="true" />
|
||||||
<option name="showLibraryContents" value="true" />
|
<option name="showLibraryContents" value="true" />
|
||||||
</component>
|
</component>
|
||||||
<component name="PropertiesComponent"><![CDATA[{
|
<component name="PropertiesComponent">{
|
||||||
"keyToString": {
|
"keyToString": {
|
||||||
"ModuleVcsDetector.initialDetectionPerformed": "true",
|
"ModuleVcsDetector.initialDetectionPerformed": "true",
|
||||||
"RunOnceActivity.RadMigrateCodeStyle": "true",
|
"RunOnceActivity.RadMigrateCodeStyle": "true",
|
||||||
"RunOnceActivity.ShowReadmeOnStart": "true",
|
"RunOnceActivity.ShowReadmeOnStart": "true",
|
||||||
"RunOnceActivity.cidr.known.project.marker": "true",
|
"RunOnceActivity.cidr.known.project.marker": "true",
|
||||||
"RunOnceActivity.git.unshallow": "true",
|
"RunOnceActivity.git.unshallow": "true",
|
||||||
"RunOnceActivity.readMode.enableVisualFormatting": "true",
|
"RunOnceActivity.readMode.enableVisualFormatting": "true",
|
||||||
"RunOnceActivity.west.config.association.type.startup.service": "true",
|
"RunOnceActivity.west.config.association.type.startup.service": "true",
|
||||||
"cf.advertisement.text.overridden": "true",
|
"cf.advertisement.text.overridden": "true",
|
||||||
"cf.first.check.clang-format": "false",
|
"cf.first.check.clang-format": "false",
|
||||||
"cidr.known.project.marker": "true",
|
"cidr.known.project.marker": "true",
|
||||||
"git-widget-placeholder": "main",
|
"git-widget-placeholder": "main",
|
||||||
"ignore.virus.scanning.warn.message": "true",
|
"ignore.virus.scanning.warn.message": "true",
|
||||||
"junie.onboarding.icon.badge.shown": "true",
|
"junie.onboarding.icon.badge.shown": "true",
|
||||||
"node.js.detected.package.eslint": "true",
|
"node.js.detected.package.eslint": "true",
|
||||||
"node.js.detected.package.tslint": "true",
|
"node.js.detected.package.tslint": "true",
|
||||||
"node.js.selected.package.eslint": "(autodetect)",
|
"node.js.selected.package.eslint": "(autodetect)",
|
||||||
"node.js.selected.package.tslint": "(autodetect)",
|
"node.js.selected.package.tslint": "(autodetect)",
|
||||||
"nodejs_package_manager_path": "npm",
|
"nodejs_package_manager_path": "npm",
|
||||||
"settings.editor.selected.configurable": "preferences.sourceCode.C++",
|
"settings.editor.selected.configurable": "preferences.sourceCode.C++",
|
||||||
"to.speed.mode.migration.done": "true",
|
"to.speed.mode.migration.done": "true",
|
||||||
"vue.rearranger.settings.migration": "true"
|
"vue.rearranger.settings.migration": "true"
|
||||||
}
|
}
|
||||||
}]]></component>
|
}</component>
|
||||||
<component name="RunManager" selected="C/C++ File.main.cpp">
|
<component name="RunManager" selected="C/C++ File.main.cpp">
|
||||||
<configuration name="assignment1" type="CMakeRunConfiguration" factoryName="Application" REDIRECT_INPUT="false" ELEVATE="false" USE_EXTERNAL_CONSOLE="false" EMULATE_TERMINAL="false" PASS_PARENT_ENVS_2="true" PROJECT_NAME="assignment1" TARGET_NAME="assignment1" CONFIG_NAME="Debug" RUN_TARGET_PROJECT_NAME="assignment1" RUN_TARGET_NAME="assignment1">
|
<configuration name="assignment1" type="CMakeRunConfiguration" factoryName="Application" REDIRECT_INPUT="false" ELEVATE="false" USE_EXTERNAL_CONSOLE="false" EMULATE_TERMINAL="false" PASS_PARENT_ENVS_2="true" PROJECT_NAME="assignment1" TARGET_NAME="assignment1" CONFIG_NAME="Debug" RUN_TARGET_PROJECT_NAME="assignment1" RUN_TARGET_NAME="assignment1">
|
||||||
<method v="2">
|
<method v="2">
|
||||||
@@ -111,6 +109,8 @@
|
|||||||
<updated>1760370577663</updated>
|
<updated>1760370577663</updated>
|
||||||
<workItem from="1760370578774" duration="118000" />
|
<workItem from="1760370578774" duration="118000" />
|
||||||
<workItem from="1760788441262" duration="11460000" />
|
<workItem from="1760788441262" duration="11460000" />
|
||||||
|
<workItem from="1760967500921" duration="5495000" />
|
||||||
|
<workItem from="1761213959983" duration="3160000" />
|
||||||
</task>
|
</task>
|
||||||
<servers />
|
<servers />
|
||||||
</component>
|
</component>
|
||||||
|
|||||||
@@ -2,8 +2,6 @@
|
|||||||
|
|
||||||
#ifndef IKT203_TMOVIE_H
|
#ifndef IKT203_TMOVIE_H
|
||||||
#define IKT203_TMOVIE_H
|
#define IKT203_TMOVIE_H
|
||||||
|
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ using namespace std;
|
|||||||
|
|
||||||
void TMovieList::Append(TMovie* m)
|
void TMovieList::Append(TMovie* m)
|
||||||
{
|
{
|
||||||
|
// Time complexity O(1) with using tail and prev nodes
|
||||||
auto* newNode = new TMovieNode(m);
|
auto* newNode = new TMovieNode(m);
|
||||||
newNode->SetPrevNode(tail);
|
newNode->SetPrevNode(tail);
|
||||||
tail->SetNextNode(newNode);
|
tail->SetNextNode(newNode);
|
||||||
@@ -24,13 +25,12 @@ void TMovieList::Prepend(TMovie* m)
|
|||||||
if (old)
|
if (old)
|
||||||
old->SetPrevNode(newNode);
|
old->SetPrevNode(newNode);
|
||||||
|
|
||||||
|
|
||||||
cout << "Prepended '" << m->GetTitle() << "' into list of movies" <<endl;
|
cout << "Prepended '" << m->GetTitle() << "' into list of movies" <<endl;
|
||||||
if (tail == head)
|
if (tail == head)
|
||||||
tail = newNode;
|
tail = newNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
TMovieNode* TMovieList::NavigateToNode(int index)
|
TMovieNode* TMovieList::NavigateToNode(const int index) const
|
||||||
{
|
{
|
||||||
// Negativ index finnes ikke -> ugyldig
|
// Negativ index finnes ikke -> ugyldig
|
||||||
if (index < 0)
|
if (index < 0)
|
||||||
@@ -51,13 +51,13 @@ TMovieNode* TMovieList::NavigateToNode(int index)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
TMovie* TMovieList::GetAtIndex(int index)
|
TMovie* TMovieList::GetAtIndex(const int index) const
|
||||||
{
|
{
|
||||||
auto* node = NavigateToNode(index);
|
auto* node = NavigateToNode(index);
|
||||||
return node ? node->GetMovie() : nullptr;
|
return node ? node->GetMovie() : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TMovieList::Remove(int index)
|
void TMovieList::Remove(const int index)
|
||||||
{
|
{
|
||||||
auto* node = NavigateToNode(index);
|
auto* node = NavigateToNode(index);
|
||||||
if (node == nullptr)
|
if (node == nullptr)
|
||||||
@@ -78,4 +78,18 @@ void TMovieList::Remove(int index)
|
|||||||
tail = head;
|
tail = head;
|
||||||
|
|
||||||
delete node;
|
delete node;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TMovie *TMovieList::SearchFor(const FCheckMovie check_movie, void *criteria) const
|
||||||
|
{
|
||||||
|
auto* node = head->GetNextNode();
|
||||||
|
while (node != nullptr)
|
||||||
|
{
|
||||||
|
if (check_movie(node->GetMovie(), criteria))
|
||||||
|
{
|
||||||
|
return node->GetMovie();
|
||||||
|
}
|
||||||
|
node = node->GetNextNode();
|
||||||
|
}
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|||||||
@@ -4,6 +4,9 @@
|
|||||||
#include "TMovie.h"
|
#include "TMovie.h"
|
||||||
#include "TMovieNode.h"
|
#include "TMovieNode.h"
|
||||||
|
|
||||||
|
// typedef to increase flexibility and reduce code recycling
|
||||||
|
typedef bool (*FCheckMovie)(TMovie* movie, void* criteria);
|
||||||
|
|
||||||
class TMovieList {
|
class TMovieList {
|
||||||
private:
|
private:
|
||||||
TMovieNode* head;
|
TMovieNode* head;
|
||||||
@@ -26,10 +29,11 @@ public:
|
|||||||
}
|
}
|
||||||
void Append(TMovie* m);
|
void Append(TMovie* m);
|
||||||
void Prepend(TMovie* m);
|
void Prepend(TMovie* m);
|
||||||
|
TMovie* SearchFor(FCheckMovie check_movie, void* criteria) const;
|
||||||
|
|
||||||
TMovieNode *NavigateToNode(int index);
|
[[nodiscard]] TMovieNode *NavigateToNode(int index) const;
|
||||||
|
|
||||||
TMovie* GetAtIndex(int index);
|
[[nodiscard]] TMovie* GetAtIndex(int index) const;
|
||||||
void Remove(int index);
|
void Remove(int index);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,32 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include "TMovieList.h"
|
||||||
|
|
||||||
|
// specialised versions of SearchFor() from TMovieList
|
||||||
|
bool SearchByTitle(const TMovie* m, void* c)
|
||||||
|
{
|
||||||
|
const auto* title = static_cast<std::string*>(c);
|
||||||
|
return m->GetTitle() == *title;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SearchByDirector(const TMovie* m, void* criteria)
|
||||||
|
{
|
||||||
|
const auto* director = static_cast<std::string*>(criteria);
|
||||||
|
return m->GetDirector() == *director;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SearchByGenre(const TMovie* m, void* criteria)
|
||||||
|
{
|
||||||
|
const auto* genre = static_cast<EMovieGenreType*>(criteria);
|
||||||
|
return m->GetGenre() == *genre;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
std::cout << "Hello, World!" << std::endl;
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user