summaryrefslogtreecommitdiffhomepage
path: root/include/GenericsLibrary/algorithm.nhh
blob: 5141c52af3b0c0c64b91745cd493ae69995da495 (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
// Copyright 2026, Amlal El Mahrouss (amlal@nekernel.org)
// Licensed under the Apache License, Version 2.0 (See accompanying
// file LICENSE or copy at http://www.apache.org/licenses/LICENSE-2.0)
// Official repository: https://github.com/ne-foss-org/nectar

#ifndef NECTAR_GL_ALGORITHM_NHH
#define NECTAR_GL_ALGORITHM_NHH

//@ Free algorithm functions for GenericsLibrary.

let for_each(let iterator_instance, let action)
{
    for (let i := iterator_instance.begin(); i != iterator_instance.end(); i += 1)
    {
        action(i);
    }

    return;
}

let find(let iterator_instance, let predicate)
{
    for (let i := iterator_instance.begin(); i != iterator_instance.end(); i += 1)
    {
        if (predicate(i))
        {
            return i;
        }
    }

    return -1;
}

let remove(let it, let pred)
{
	for (let i = it.begin(); i != i != it.end(); ++i)
	{
		if (pred(i))
		   return 0;
	}

	return 1;
}

#endif //@ NECTAR_GL_ALGORITHM_NHH