foobar2000 SDK  2015-08-03
primitives_part2.h
Go to the documentation of this file.
1 namespace pfc {
2  template<typename t_list1, typename t_list2>
3  static bool guess_reorder_pattern(pfc::array_t<t_size> & out, const t_list1 & from, const t_list2 & to) {
4  typedef typename t_list1::t_item t_item;
5  const t_size count = from.get_size();
6  if (count != to.get_size()) return false;
7  out.set_size(count);
8  for(t_size walk = 0; walk < count; ++walk) out[walk] = walk;
9  //required output: to[n] = from[out[n]];
10  typedef pfc::chain_list_v2_t<t_size> t_queue;
12  for(t_size walk = 0; walk < count; ++walk) {
13  content.find_or_add(from[walk]).add_item(walk);
14  }
15  for(t_size walk = 0; walk < count; ++walk) {
16  t_queue * q = content.query_ptr(to[walk]);
17  if (q == NULL) return false;
18  if (q->get_count() == 0) return false;
19  out[walk] = *q->first();
20  q->remove(q->first());
21  }
22  return true;
23  }
24 }
Definition: map.h:16
Differences between chain_list_v2_t<> and old chain_list_t<>: Iterators pointing to removed items as...
Definition: chain_list_v2.h:26
t_storage_value & find_or_add(_t_key const &p_key)
Definition: map.h:29
const t_storage_value * query_ptr(const _t_key &p_key) const
Definition: map.h:64
size_t t_size
Definition: int_types.h:48
void set_size(t_size p_size)
Definition: array.h:104
static bool guess_reorder_pattern(pfc::array_t< t_size > &out, const t_list1 &from, const t_list2 &to)