From 7f17278493da389ea25a627ea993a35f122671ef Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Fri, 23 Jan 2026 19:46:09 +0100 Subject: chore: GenericsLibrary: Library tweaks and additions, more examples for Nectar and Assembly. Signed-off-by: Amlal El Mahrouss --- include/GenericsLibrary/algorithm.nhh | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 include/GenericsLibrary/algorithm.nhh (limited to 'include/GenericsLibrary/algorithm.nhh') diff --git a/include/GenericsLibrary/algorithm.nhh b/include/GenericsLibrary/algorithm.nhh new file mode 100644 index 0000000..b62faa1 --- /dev/null +++ b/include/GenericsLibrary/algorithm.nhh @@ -0,0 +1,34 @@ +// 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/nekernel-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; +} + +#endif //@ NECTAR_GL_ALGORITHM_NHH \ No newline at end of file -- cgit v1.2.3