mirror of
https://github.com/enduro2d/enduro2d.git
synced 2025-12-13 15:48:11 +07:00
39 lines
1.2 KiB
C++
39 lines
1.2 KiB
C++
/*******************************************************************************
|
|
* This file is part of the "https://github.com/blackmatov/flat.hpp"
|
|
* For conditions of distribution and use, see copyright notice in LICENSE.md
|
|
* Copyright (C) 2019, by Matvey Cherevko (blackmatov@gmail.com)
|
|
******************************************************************************/
|
|
|
|
#pragma once
|
|
|
|
namespace flat_hpp::detail
|
|
{
|
|
template < typename Iter, typename Compare >
|
|
bool is_sorted(Iter first, Iter last, Compare comp) {
|
|
if ( first != last ) {
|
|
Iter next = first;
|
|
while ( ++next != last ) {
|
|
if ( comp(*next, *first) ) {
|
|
return false;
|
|
}
|
|
++first;
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
template < typename Iter, typename Compare >
|
|
bool is_sorted_unique(Iter first, Iter last, Compare comp) {
|
|
if ( first != last ){
|
|
Iter next = first;
|
|
while ( ++next != last ) {
|
|
if ( !comp(*first, *next) ) {
|
|
return false;
|
|
}
|
|
++first;
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
}
|