summaryrefslogtreecommitdiff
path: root/src/iterators.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/iterators.cc')
-rw-r--r--src/iterators.cc60
1 files changed, 31 insertions, 29 deletions
diff --git a/src/iterators.cc b/src/iterators.cc
index 63cbb9b2..020f70b0 100644
--- a/src/iterators.cc
+++ b/src/iterators.cc
@@ -173,46 +173,22 @@ account_t * basic_accounts_iterator::operator()()
return account;
}
-void sorted_accounts_iterator::sort_accounts(account_t& account,
- accounts_deque_t& deque)
-{
- foreach (accounts_map::value_type& pair, account.accounts)
- deque.push_back(pair.second);
-
- std::stable_sort(deque.begin(), deque.end(),
- compare_items<account_t>(sort_cmp));
-
-#if defined(DEBUG_ON)
- if (SHOW_DEBUG("accounts.sorted")) {
- foreach (account_t * account, deque)
- DEBUG("accounts.sorted", "Account: " << account->fullname());
- }
-#endif
-}
-
-void sorted_accounts_iterator::push_all(account_t& account)
-{
- accounts_deque_t& deque(accounts_list.back());
-
- foreach (accounts_map::value_type& pair, account.accounts) {
- deque.push_back(pair.second);
- push_all(*pair.second);
- }
-}
-
void sorted_accounts_iterator::push_back(account_t& account)
{
accounts_list.push_back(accounts_deque_t());
if (flatten_all) {
- push_all(account);
+ push_all(account, accounts_list.back());
+
std::stable_sort(accounts_list.back().begin(),
accounts_list.back().end(),
compare_items<account_t>(sort_cmp));
+
#if defined(DEBUG_ON)
if (SHOW_DEBUG("accounts.sorted")) {
foreach (account_t * account, accounts_list.back())
- DEBUG("accounts.sorted", "Account: " << account->fullname());
+ DEBUG("accounts.sorted",
+ "Account (flat): " << account->fullname());
}
#endif
} else {
@@ -223,6 +199,32 @@ void sorted_accounts_iterator::push_back(account_t& account)
sorted_accounts_end.push_back(accounts_list.back().end());
}
+void sorted_accounts_iterator::push_all(account_t& account,
+ accounts_deque_t& deque)
+{
+ foreach (accounts_map::value_type& pair, account.accounts) {
+ deque.push_back(pair.second);
+ push_all(*pair.second, deque);
+ }
+}
+
+void sorted_accounts_iterator::sort_accounts(account_t& account,
+ accounts_deque_t& deque)
+{
+ foreach (accounts_map::value_type& pair, account.accounts)
+ deque.push_back(pair.second);
+
+ std::stable_sort(deque.begin(), deque.end(),
+ compare_items<account_t>(sort_cmp));
+
+#if defined(DEBUG_ON)
+ if (SHOW_DEBUG("accounts.sorted")) {
+ foreach (account_t * account, deque)
+ DEBUG("accounts.sorted", "Account: " << account->fullname());
+ }
+#endif
+}
+
account_t * sorted_accounts_iterator::operator()()
{
while (! sorted_accounts_i.empty() &&