comparison foosdk/sdk/pfc/primitives_part2.h @ 1:20d02a178406 default tip

*: check in everything else yay
author Paper <paper@tflc.us>
date Mon, 05 Jan 2026 02:15:46 -0500
parents
children
comparison
equal deleted inserted replaced
0:e9bb126753e7 1:20d02a178406
1 #pragma once
2
3 namespace pfc {
4 template<typename t_list1, typename t_list2>
5 static bool guess_reorder_pattern(pfc::array_t<t_size> & out, const t_list1 & from, const t_list2 & to) {
6 typedef typename t_list1::t_item t_item;
7 const t_size count = from.get_size();
8 if (count != to.get_size()) return false;
9 out.set_size(count);
10 for(t_size walk = 0; walk < count; ++walk) out[walk] = walk;
11 //required output: to[n] = from[out[n]];
12 typedef pfc::chain_list_v2_t<t_size> t_queue;
13 pfc::map_t<t_item, t_queue > content;
14 for(t_size walk = 0; walk < count; ++walk) {
15 content.find_or_add(from[walk]).add_item(walk);
16 }
17 for(t_size walk = 0; walk < count; ++walk) {
18 t_queue * q = content.query_ptr(to[walk]);
19 if (q == NULL) return false;
20 if (q->get_count() == 0) return false;
21 out[walk] = *q->first();
22 q->remove(q->first());
23 }
24 return true;
25 }
26 }