VariantKey  5.4.1
Numerical Encoding for Human Genetic Variants
set.h File Reference

Utility functions to sort and join uint64_t arrays. More...

#include <inttypes.h>
#include <stdlib.h>

Go to the source code of this file.

Macros

#define RADIX_SORT_COUNT_BLOCK
 
#define RADIX_SORT_ITERATION_BLOCK(A, B, BYTE, SHIFT)
 

Functions

static void sort_uint64_t (uint64_t *arr, uint64_t *tmp, uint32_t nitems)
 
static void order_uint64_t (uint64_t *arr, uint64_t *tmp, uint32_t *idx, uint32_t *tdx, uint32_t nitems)
 
static void reverse_uint64_t (uint64_t *arr, uint64_t nitems)
 
static uint64_t * unique_uint64_t (uint64_t *arr, uint64_t nitems)
 
static uint64_t * intersection_uint64_t (uint64_t *a_arr, uint64_t a_nitems, uint64_t *b_arr, uint64_t b_nitems, uint64_t *o_arr)
 
static uint64_t * union_uint64_t (uint64_t *a_arr, uint64_t a_nitems, uint64_t *b_arr, uint64_t b_nitems, uint64_t *o_arr)
 

Detailed Description

Collection of utility functions to sort and join uint64_t arrays.

Macro Definition Documentation

#define RADIX_SORT_COUNT_BLOCK
#define RADIX_SORT_ITERATION_BLOCK (   A,
  B,
  BYTE,
  SHIFT 
)
Value:
for (i = 0; i < nitems; i++) \
{ \
v = (A)[i]; \
(B)[c##BYTE[((v >> (SHIFT)) & 0xff)]++] = v; \
}

Function Documentation

static uint64_t* intersection_uint64_t ( uint64_t *  a_arr,
uint64_t  a_nitems,
uint64_t *  b_arr,
uint64_t  b_nitems,
uint64_t *  o_arr 
)
inlinestatic

Returns the intersection of two sorted uint64_t arrays.

Parameters
a_arrPointer to the first element of the first array to process.
a_nitemsNumber of elements in the first array.
b_arrPointer to the first element of the second array to process.
b_nitemsNumber of elements in the second array.
o_arrPointer to the first element or the output array.
Returns
Pointer to the end of the array.
static void order_uint64_t ( uint64_t *  arr,
uint64_t *  tmp,
uint32_t *  idx,
uint32_t *  tdx,
uint32_t  nitems 
)
inlinestatic

Sorts in-memory an array of uint64_t values in ascending order ans store the permutation order index.

Parameters
arrPointer to the first element of the array to process.
tmpPointer to the first element of a temporary array.
idxPointer to the first element of the index array to be returned.
tdxPointer to the first element of a temporary index array.
nitemsNumber of elements in the array.
static void reverse_uint64_t ( uint64_t *  arr,
uint64_t  nitems 
)
inlinestatic

Reverse in-place an array of uint64_t values.

Parameters
arrPointer to the first element of the array to process.
nitemsNumber of elements in the array.
static void sort_uint64_t ( uint64_t *  arr,
uint64_t *  tmp,
uint32_t  nitems 
)
inlinestatic

Sorts in-memory an array of uint64_t values in ascending order.

Parameters
arrPointer to the first element of the array to process.
tmpPointer to the first element of a temporary array.
nitemsNumber of elements in the array.
static uint64_t* union_uint64_t ( uint64_t *  a_arr,
uint64_t  a_nitems,
uint64_t *  b_arr,
uint64_t  b_nitems,
uint64_t *  o_arr 
)
inlinestatic

Returns the union of two sorted uint64_t arrays.

Parameters
a_arrPointer to the first element of the first array to process.
a_nitemsNumber of elements in the first array.
b_arrPointer to the first element of the second array to process.
b_nitemsNumber of elements in the second array.
o_arrPointer to the first element or the output array.
Returns
Pointer to the end of the array.
static uint64_t* unique_uint64_t ( uint64_t *  arr,
uint64_t  nitems 
)
inlinestatic

Eliminates all but the first element from every consecutive group of equal values.

Parameters
arrPointer to the first element of the array to process.
nitemsNumber of elements in the array.
Returns
Pointer to the end of the array.