Documentation - C API
shuffle-def.h File Reference

Shuffle preprocessor metaprogram. More...

#include "host.h"
#include "random.h"
#include <assert.h>

Macros

#define VL_SHUFFLE_array   VL_SHUFFLE_type*
#define VL_SHUFFLE_prefix   ShufflePrefix
#define VL_SHUFFLE_type   ShuffleType
#define VL_SHUFFLE_array   ShuffleType*

Functions

void VL_SHUFFLE_swap (VL_SHUFFLE_array array, vl_uindex indexA, vl_uindex indexB)
 Swap two array elements.
void VL_SHUFFLE_shuffle (VL_SHUFFLE_array array, vl_size size, VlRand *rand)
 Shuffle.

Detailed Description

Author:
Andrea Vedaldi
Todo:
large array compatibility.

Macro Definition Documentation

#define VL_SHUFFLE_array   VL_SHUFFLE_type*

Data type of the shuffle container

#define VL_SHUFFLE_array   ShuffleType*

Data type of the shuffle container

#define VL_SHUFFLE_prefix   ShufflePrefix

Prefix of the shuffle functions

#define VL_SHUFFLE_type   ShuffleType

Data type of the shuffle elements


Function Documentation

void VL_SHUFFLE_shuffle ( VL_SHUFFLE_array  array,
vl_size  size,
VlRand rand 
)
inline
Parameters:
array(in/out) pointer to the array.
sizesize of the array.
randrandom number generator to use.

The function randomly permutes the array.

void VL_SHUFFLE_swap ( VL_SHUFFLE_array  array,
vl_uindex  indexA,
vl_uindex  indexB 
)
inline
Parameters:
arrayshuffle array.
indexAindex of the first element to swap.
indexBindex of the second element to swap.

The function swaps the two elements a and @ b. The function uses a temporary element of type VL_SHUFFLE_type and the copy operator =.