Mercurial > foo_out_sdl
diff 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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/foosdk/sdk/pfc/primitives_part2.h Mon Jan 05 02:15:46 2026 -0500 @@ -0,0 +1,26 @@ +#pragma once + +namespace pfc { + template<typename t_list1, typename t_list2> + static bool guess_reorder_pattern(pfc::array_t<t_size> & out, const t_list1 & from, const t_list2 & to) { + typedef typename t_list1::t_item t_item; + const t_size count = from.get_size(); + if (count != to.get_size()) return false; + out.set_size(count); + for(t_size walk = 0; walk < count; ++walk) out[walk] = walk; + //required output: to[n] = from[out[n]]; + typedef pfc::chain_list_v2_t<t_size> t_queue; + pfc::map_t<t_item, t_queue > content; + for(t_size walk = 0; walk < count; ++walk) { + content.find_or_add(from[walk]).add_item(walk); + } + for(t_size walk = 0; walk < count; ++walk) { + t_queue * q = content.query_ptr(to[walk]); + if (q == NULL) return false; + if (q->get_count() == 0) return false; + out[walk] = *q->first(); + q->remove(q->first()); + } + return true; + } +}
