File indexing completed on 2024-04-28 04:41:40

0001 /*
0002     SPDX-FileCopyrightText: 2019 Volker Krause <vkrause@kde.org>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #include "requestcontext_p.h"
0008 
0009 using namespace KPublicTransport;
0010 
0011 RequestContext::RequestContext() = default;
0012 RequestContext::~RequestContext() = default;
0013 
0014 bool RequestContext::operator==(const RequestContext &other) const
0015 {
0016     return backend == other.backend
0017         && type == other.type
0018         && dateTime == other.dateTime
0019         && backendData == other.backendData;
0020 }
0021 
0022 bool RequestContext::operator<(const AbstractBackend *other) const
0023 {
0024     return backend < other;
0025 }
0026 
0027 void RequestContext::purgeLoops(std::vector<RequestContext> &contexts, const std::vector<RequestContext> &baseContexts)
0028 {
0029     for (auto it = contexts.begin(); it != contexts.end();) {
0030         const auto baseIt = std::lower_bound(baseContexts.begin(), baseContexts.end(), (*it).backend);
0031         if (baseIt != baseContexts.end() && (*baseIt) == (*it)) {
0032             it = contexts.erase(it);
0033         } else {
0034             ++it;
0035         }
0036     }
0037 }