From d38e9ca1b962d1294a61ea032e681149ff4caf27 Mon Sep 17 00:00:00 2001 From: RickyRister Date: Sat, 1 Mar 2025 20:18:50 -0800 Subject: [PATCH] change signature to use lambda --- common/decklist.cpp | 16 ++++++++++++++++ common/decklist.h | 18 +----------------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/common/decklist.cpp b/common/decklist.cpp index 789f57910..0f9ad7b62 100644 --- a/common/decklist.cpp +++ b/common/decklist.cpp @@ -994,3 +994,19 @@ void DeckList::refreshDeckHash() cachedDeckHash = QString(); emit deckHashChanged(); } + +/** + * Calls a given function on each card in the deck. + */ +void DeckList::forEachCard(const std::function &func) +{ + // Support for this is only possible if the internal structure + // doesn't get more complicated. + for (int i = 0; i < root->size(); i++) { + InnerDecklistNode *node = dynamic_cast(root->at(i)); + for (int j = 0; j < node->size(); j++) { + DecklistCardNode *card = dynamic_cast(node->at(j)); + func(node, card); + } + } +} \ No newline at end of file diff --git a/common/decklist.h b/common/decklist.h index de839ad23..989c3e7fe 100644 --- a/common/decklist.h +++ b/common/decklist.h @@ -381,23 +381,7 @@ public: QString getDeckHash() const; void refreshDeckHash(); - /** - * Calls a given function object for each card in the deck. It must - * take a InnerDecklistNode* as its first argument and a - * DecklistCardNode* as its second. - */ - template void forEachCard(Callback &callback) - { - // Support for this is only possible if the internal structure - // doesn't get more complicated. - for (int i = 0; i < root->size(); i++) { - InnerDecklistNode *node = dynamic_cast(root->at(i)); - for (int j = 0; j < node->size(); j++) { - DecklistCardNode *card = dynamic_cast(node->at(j)); - callback(node, card); - } - } - } + void forEachCard(const std::function &func); }; #endif \ No newline at end of file