File indexing completed on 2024-05-12 16:59:21
0001 /* 0002 * SPDX-FileCopyrightText: 2015-2016 Ivan Cukic <ivan.cukic@kde.org> 0003 * 0004 * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0005 */ 0006 0007 #ifndef UTILS_SLIDE_H 0008 #define UTILS_SLIDE_H 0009 0010 #include <algorithm> 0011 0012 // Inspired by C++ Seasoning talk by Sean Parent 0013 0014 namespace kamd 0015 { 0016 namespace utils 0017 { 0018 template<typename Iterator> 0019 void slide(Iterator f, Iterator l, Iterator p) 0020 { 0021 if (p < f) { 0022 std::rotate(p, f, l); 0023 } else if (l < p) { 0024 std::rotate(f, l, p); 0025 } 0026 } 0027 0028 template<typename Iterator> 0029 void slide_one(Iterator f, Iterator p) 0030 { 0031 slide(f, f + 1, p); 0032 } 0033 0034 } // namespace utils 0035 } // namespace kamd 0036 0037 #endif // UTILS_SLIDE_H