12 for(
t_size walk = 0; walk < count; ++walk) {
13 if (order[walk] >= count)
return false;
14 if (found[walk])
return false;
24 if (value >= count)
return ~0;
25 for(
t_size walk = 0; walk < count; ++walk) {
26 if (order[walk] == value)
return walk;
32 t_size *
const order = p_output;
33 const t_size count = p_count;
37 for(
t_size walk = 0; walk < count; ++walk) {
39 selection[walk] = p_selection[walk];
44 for(;p_delta<0;p_delta++)
47 for(idx=1;idx<count;idx++)
49 if (selection[idx] && !selection[idx-1])
59 for(;p_delta>0;p_delta--)
62 for(idx=count-2;(int)idx>=0;idx--)
64 if (selection[idx] && !selection[idx+1])
78 data[ptr1] = data[ptr2];
85 t_size prev = val, next = order[val];
99 t_size base2 = base+count-1;
101 g_swap(order,base+n,base2-n);
117 for(n=0;n<p_bytes>>1;n++)
swap_t(ptr[n],ptr[p_bytes-n-1]);
120 #if defined(_DEBUG) && defined(_WIN32)
121 void pfc::myassert(
const wchar_t * _Message,
const wchar_t *_File,
unsigned _Line) {
123 _wassert(_Message,_File,_Line);
150 exp = (unsigned) -expS;
153 exp = (unsigned) expS;
160 if (exp & 1) v *= mul;
167 for(
unsigned i = 0; i < exp; ++i) {
171 if (neg) v = 1.0 / v;
double exp_int(double base, int exp)
t_uint64 pow_int(t_uint64 base, t_uint64 exp)
void byteswap_raw(void *p_buffer, t_size p_bytes)
Generic variable bit_array implementation. Needs to be initialized with requested array size before ...
Bit array interface class, constant version (you can only retrieve values). Range of valid indexes d...
void set(t_size n, bool val)
static void g_swap(t_size *p_data, t_size ptr1, t_size ptr2)
void permutation_validate(t_size const *order, t_size count)
For critical sanity checks. Speed: O(n), allocates memory.
t_size permutation_find_reverse(t_size const *order, t_size count, t_size value)
void set_size(t_size p_size)
static void g_reverse(t_size *order, t_size base, t_size count)
void myassert(const wchar_t *_Message, const wchar_t *_File, unsigned _Line)
bool permutation_is_valid(t_size const *order, t_size count)
For critical sanity checks. Speed: O(n), allocates memory.
void create_move_items_permutation(t_size *p_output, t_size p_count, const class bit_array &p_selection, int p_delta)
Creates a permutation that moves selected items in a list box by the specified delta-offset.
static t_size g_find_reverse(const t_size *order, t_size val)
Insecure - may deadlock or crash on invalid permutation content. In theory faster than walking the pe...
void swap_t(T &p_item1, T &p_item2)