136ac495dSmrg // -*- C++ -*- 236ac495dSmrg 3*8feb0f0bSmrg // Copyright (C) 2007-2020 Free Software Foundation, Inc. 436ac495dSmrg // 536ac495dSmrg // This file is part of the GNU ISO C++ Library. This library is free 636ac495dSmrg // software; you can redistribute it and/or modify it under the terms 736ac495dSmrg // of the GNU General Public License as published by the Free Software 836ac495dSmrg // Foundation; either version 3, or (at your option) any later 936ac495dSmrg // version. 1036ac495dSmrg 1136ac495dSmrg // This library is distributed in the hope that it will be useful, but 1236ac495dSmrg // WITHOUT ANY WARRANTY; without even the implied warranty of 1336ac495dSmrg // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 1436ac495dSmrg // General Public License for more details. 1536ac495dSmrg 1636ac495dSmrg // Under Section 7 of GPL version 3, you are granted additional 1736ac495dSmrg // permissions described in the GCC Runtime Library Exception, version 1836ac495dSmrg // 3.1, as published by the Free Software Foundation. 1936ac495dSmrg 2036ac495dSmrg // You should have received a copy of the GNU General Public License and 2136ac495dSmrg // a copy of the GCC Runtime Library Exception along with this program; 2236ac495dSmrg // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see 2336ac495dSmrg // <http://www.gnu.org/licenses/>. 2436ac495dSmrg 2536ac495dSmrg /** @file parallel/checkers.h 2636ac495dSmrg * @brief Routines for checking the correctness of algorithm results. 2736ac495dSmrg * This file is a GNU parallel extension to the Standard C++ Library. 2836ac495dSmrg */ 2936ac495dSmrg 3036ac495dSmrg // Written by Johannes Singler. 3136ac495dSmrg 3236ac495dSmrg #ifndef _GLIBCXX_PARALLEL_CHECKERS_H 3336ac495dSmrg #define _GLIBCXX_PARALLEL_CHECKERS_H 1 3436ac495dSmrg 3536ac495dSmrg #include <cstdio> 3636ac495dSmrg #include <bits/stl_algobase.h> 3736ac495dSmrg #include <bits/stl_function.h> 3836ac495dSmrg 3936ac495dSmrg namespace __gnu_parallel 4036ac495dSmrg { 4136ac495dSmrg /** 4236ac495dSmrg * @brief Check whether @c [__begin, @c __end) is sorted according 4336ac495dSmrg * to @c __comp. 4436ac495dSmrg * @param __begin Begin iterator of sequence. 4536ac495dSmrg * @param __end End iterator of sequence. 4636ac495dSmrg * @param __comp Comparator. 4736ac495dSmrg * @return @c true if sorted, @c false otherwise. 4836ac495dSmrg */ 4936ac495dSmrg template<typename _IIter, typename _Compare> 5036ac495dSmrg bool __is_sorted(_IIter __begin,_IIter __end,_Compare __comp)5136ac495dSmrg __is_sorted(_IIter __begin, _IIter __end, _Compare __comp) 5236ac495dSmrg { 5336ac495dSmrg if (__begin == __end) 5436ac495dSmrg return true; 5536ac495dSmrg 5636ac495dSmrg _IIter __current(__begin), __recent(__begin); 5736ac495dSmrg 5836ac495dSmrg for (__current++; __current != __end; __current++) 5936ac495dSmrg { 6036ac495dSmrg if (__comp(*__current, *__recent)) 6136ac495dSmrg { 6236ac495dSmrg return false; 6336ac495dSmrg } 6436ac495dSmrg __recent = __current; 6536ac495dSmrg } 6636ac495dSmrg 6736ac495dSmrg return true; 6836ac495dSmrg } 6936ac495dSmrg } 7036ac495dSmrg 7136ac495dSmrg #endif /* _GLIBCXX_PARALLEL_CHECKERS_H */ 72