acme
Foundational cross-platform layer of the ca2 framework
Loading...
Searching...
No Matches
_function.h
1// Created by camilo on 2023-07-09 19:09 <3ThomasBorregaardSorensen!!
2#pragma once
3
4
5#include "_sort.h"
6
7
8// take in accptr that _001RemoveIndexes machine
9// the ::collection::index raw_array by sorting it and returning
10// only the indexes that could be erased
11// without indexes duplicates
12template < prototype_array ARRAY, prototype_array ARRAY_INDEXES >
13void _001RemoveIndexes(ARRAY & a, ARRAY_INDEXES & ia)
14{
15
16 // sort
17 //::sort::quick_sort(ia,true);
18
19 ::sort::QuickSortAsc(ia);
20
21 ::collection::index i = ia.get_upper_bound();
22
23 // filter out of upper bound indexes
24 while (i >= 0 && ia[i] >= a.get_size())
25 {
26
27 ia.erase_at(i);
28
29 i--;
30
31 }
32
33 // filter out of lower bound indexes
34 while (ia.get_size() > 0 && ia[0] < 0)
35 {
36
37 ia.erase_at(0);
38
39 }
40
41 i = ia.get_upper_bound();
42
43 // filter out duplicates
44 while (i > 0 && ia[i] >= a.get_size())
45 {
46
47 if (ia[i] == ia[i - 1])
48 ia.erase_at(i);
49
50 i--;
51
52 }
53
54 a.erase_indexes(ia);
55
56}
57
58
59