summaryrefslogtreecommitdiff
path: root/src/jit/jitstd/algorithm.h
blob: 7b6447e1a5fa63c2b751232b5ae48929d153ab36 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.



#pragma once

namespace jitstd
{

template <typename InputIterator, typename CompareValue>
InputIterator find(InputIterator first, InputIterator last,
                   const CompareValue& value)
{
    for (; first != last; ++first)
    {
        if (*first == value)
        {
            return first;
        }
    }
    return last;
}

template <typename InputIterator, typename Pred>
InputIterator find_if(InputIterator first, InputIterator last, const Pred& pred)
{
    for (; first != last; ++first)
    {
        if (pred(*first))
        {
            return first;
        }
    }
    return last;
}

template<typename InputIterator, typename Function>
Function for_each(InputIterator first, InputIterator last, Function func)
{
    for (; first != last; ++first)
    {
        func(*first);
    }
    return func;
}

}