Warning, file /frameworks/kcalendarcore/src/recurrencehelper_p.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /* 0002 This file is part of the kcalcore library. 0003 0004 SPDX-FileCopyrightText: 2019 Volker Krause <vkrause@kde.org> 0005 0006 SPDX-License-Identifier: LGPL-2.0-or-later 0007 */ 0008 0009 #ifndef KCALCORE_RECURRENCEHELPER_P_H 0010 #define KCALCORE_RECURRENCEHELPER_P_H 0011 0012 #include <algorithm> 0013 0014 namespace KCalendarCore 0015 { 0016 template<typename T> 0017 inline void sortAndRemoveDuplicates(T &container) 0018 { 0019 std::sort(container.begin(), container.end()); 0020 container.erase(std::unique(container.begin(), container.end()), container.end()); 0021 } 0022 0023 template<typename T> 0024 inline void inplaceSetDifference(T &set1, const T &set2) 0025 { 0026 auto beginIt = set1.begin(); 0027 for (const auto &elem : set2) { 0028 const auto it = std::lower_bound(beginIt, set1.end(), elem); 0029 if (it != set1.end() && *it == elem) { 0030 beginIt = set1.erase(it); 0031 } 0032 } 0033 } 0034 0035 template<typename Container, typename Value> 0036 inline void setInsert(Container &c, const Value &v) 0037 { 0038 const auto it = std::lower_bound(c.begin(), c.end(), v); 0039 if (it == c.end() || *it != v) { 0040 c.insert(it, v); 0041 } 0042 } 0043 0044 template<typename It, typename Value> 0045 inline It strictLowerBound(It begin, It end, const Value &v) 0046 { 0047 const auto it = std::lower_bound(begin, end, v); 0048 if (it == end || (*it) >= v) { 0049 return it == begin ? end : (it - 1); 0050 } 0051 return it; 0052 } 0053 0054 } 0055 0056 #endif