uint8

Overview

Module with functions and types to work with uint8_t values.

Types and Definitions

Generated

cUint8Slice

struct cUint8Slice
{
   int64_t s;
   uint8_t const* v;
};
typedef struct cUint8Slice cUint8Slice;

Via the macros SLICE_DEF_C_ and SLICE_IMPL_C_ declared and implemented struct. The macros declare and implement also the following functions.

/* init */
cUint8Slice uint8_slice_c( int64_t s, uint8_t const* v );
cUint8Slice make_uint8_slice_c( uint8_t const* beg, uint8_t const* end );
cUint8Slice empty_uint8_slice_c( void );
/* sub */
cUint8Slice left_uint8_slice_c( cUint8Slice slice, int64_t maxLen );
cUint8Slice mid_uint8_slice_c( cUint8Slice slice, int64_t index );
cUint8Slice right_uint8_slice_c( cUint8Slice slice, int64_t maxLen );
cUint8Slice sub_uint8_slice_c( cUint8Slice slice,
                               int64_t begIdx,
                               int64_t endIdx );

cVarUint8Slice

struct cVarUint8Slice
{
   int64_t s;
   uint8_t* v;
};
typedef struct cVarUint8Slice cVarUint8Slice;

Via the macros SLICE_DEF_C_ and SLICE_IMPL_C_ declared and implemented struct. The macros declare and implement also the following functions.

/* init */
cVarUint8Slice var_uint8_slice_c( int64_t s, uint8_t const* v );
cVarUint8Slice make_var_uint8_slice_c( uint8_t* beg, uint8_t* end );
cVarUint8Slice empty_var_uint8_slice_c( void );
/* sub */
cVarUint8Slice left_var_uint8_slice_c( cVarUint8Slice slice, int64_t maxLen );
cVarUint8Slice mid_var_uint8_slice_c( cVarUint8Slice slice, int64_t index );
cVarUint8Slice right_var_uint8_slice_c( cVarUint8Slice slice, int64_t maxLen );
cVarUint8Slice sub_var_uint8_slice_c( cVarUint8Slice slice,
                                      int64_t begIdx,
                                      int64_t endIdx );
/* var slice */
cUint8Slice as_uint8_slice_c( cVarUint8Slice slice );
cVarUint8Slice cast_uint8_slice_c( cVarUint8Slice slice, cUint8Slice sub );
int64_t set_uint8_slice_c( cVarUint8Slice dst, cUint8Slice src );

cUint8Chunk

struct cUint8Chunk
{
   int64_t s;
   uint8_t const* v;
   int64_t favSize;
   cUint8Slice slice;
};
typedef struct cUint8Chunk cUint8Chunk;

Via the macros CHUNK_DEF_C_ and CHUNK_IMPL_C_ declared and implemented struct. The macros declare and implement also the following functions.

void init_back_uint8_chunk_c( cUint8Chunk chunk[static 1],
                              int64_t s,
                              cUint8Slice slice );
void init_front_uint8_chunk_c( cUint8Chunk chunk[static 1],
                               int64_t s,
                               cUint8Slice slice );

cVarUint8Chunk

struct cVarUint8Chunk
{
   int64_t s;
   uint8_t* v;
   int64_t favSize;
   cUint8Slice slice;
};
typedef struct cVarUint8Chunk cVarUint8Chunk;

Via the macros CHUNK_DEF_C_ and CHUNK_IMPL_C_ declared and implemented struct. The macros declare and implement also the following functions.

void init_back_var_uint8_chunk_c( cVarUint8Chunk chunk[static 1],
                                  int64_t s,
                                  cVarUint8Slice slice );
void init_front_var_uint8_chunk_c( cVarUint8Chunk chunk[static 1],
                                   int64_t s,
                                   cVarUint8Slice slice );

cUint8Window

struct cUint8Window
{
   int64_t s;
   uint8_t const* v;
   int64_t favSize;
   cUint8Slice slice;
};
typedef struct cUint8Window cUint8Window;

Via the macros WINDOW_DEF_C_ and WINDOW_IMPL_C_ declared and implemented struct. The macros declare and implement also the following functions.

void init_back_uint8_window_c( cUint8Window window[static 1],
                               int64_t s,
                               cUint8Slice slice );
void init_front_uint8_window_c( cUint8Window window[static 1],
                                int64_t s,
                                cUint8Slice slice );

cVarUint8Window

struct cVarUint8Window
{
   int64_t s;
   uint8_t* v;
   int64_t favSize;
   cVarUint8Slice slice;
};
typedef struct cVarUint8Window cVarUint8Window;

Via the macros WINDOW_DEF_C_ and WINDOW_IMPL_C_ declared and implemented struct. The macros declare and implement also the following functions.

void init_back_var_uint8_window_c( cVarUint8Window window[static 1],
                                   int64_t s,
                                   cVarUint8Slice slice );
void init_front_var_uint8_window_c( cVarUint8Window window[static 1],
                                    int64_t s,
                                    cVarUint8Slice slice );

Functions

overall

cmp_uint8_c

int cmp_uint8_c( uint8_t a, uint8_t b );

Compares two uint8_t values and returns the three possible results:

<0

means that a is less compared to b

0

means that a and b are equal

>0

means that a is greater compared to b

Example
#include "clingo/lang/expect.h"
#include "clingo/type/uint8.h"

int main( void )
{
   init_tap_c_();

   expect_lt_c_( cmp_uint8_c(   0, 127 ) );
   expect_lt_c_( cmp_uint8_c( 126, 127 ) );
   expect_eq_c_( cmp_uint8_c( 127, 127 ) );
   expect_gt_c_( cmp_uint8_c( 128, 127 ) );
   expect_gt_c_( cmp_uint8_c( 255, 127 ) );

   return finish_tap_c_();
}

uint8_c_

#define uint8_c_( Value )

Macro function that casts the Value as uint8_t.

conv

int64_to_uint8_c

bool int64_to_uint8_c( int64_t src, uint8_t dst[static 1] );

Via the macro CONV_C_ implemented function. Returns true if the int64_t value can be represented in a uint8_t variable, ohterwise false.

Example
#include "clingo/lang/expect.h"
#include "clingo/type/uint8.h"

int main( void )
{
   init_tap_c_();

   uint8_t u8 = 0;

   // ------------------------------------------------------------ max - int32_t
   int32_t i32 = 255;   // UINT8_MAX
   expect_c_( int64_to_uint8_c( i32, &u8 ) );
   expect_c_( u8 == 255 );

   ++i32;   // 256
   expect_c_( not int64_to_uint8_c( i32, &u8 ) );

   // ------------------------------------------------------------- min - int8_t
   int8_t i8 = 0;
   expect_c_( int64_to_uint8_c( i8, &u8 ) );
   expect_c_( u8 == 0 );

   --i8; // -1
   expect_c_( not int64_to_uint8_c( i8, &u8 ) );

   return finish_tap_c_();
}

uint64_to_uint8_c

bool uint64_to_uint8_c( uint64_t src, uint8_t dst[static 1] );

Via the macro CONV_C_ implemented function. Returns true if the uint64_t value can be represented in a uint8_t variable, otherwise false.

Example

algo

cmp_uint8_slice_c

int cmp_uint8_slice_c( cUint8Slice a, cUint8Slice b );

Via the macro CMP_SLICE_C_ implemented function.

count_eq_uint8_c

int64_t count_eq_uint8_c( cUint8Slice slice, uint8_t val );

Via the macro COUNT_EQ_C_ implemented function.

find_uint8_c

uint8_t const* find_uint8_c( cUint8Slice slice, uint8_t val );

Via the macro FIND_VAL_C_ implemented function.

max_uint8_c

uint8_t const* max_uint8_c( cUint8Slice slice );

Via the macro FIND_MAX_C_ implemented function.

min_uint8_c

uint8_t const* min_uint8_c( cUint8Slice slice );

Via the macro FIND_MIN_C_ implemented function.

prod_uint8_c

bool prod_uint8_c( cUint8Slice slice, uint64_t res[static 1] );

Builds the product all values in the slice and saves the result in res. Return false if a overflow occures, otherwise true.

qsort_uint8_slice_c

void qsort_uint8_slice_c( cVarUint8Slice slice );

Via the macro QSORT_C_ implemented function.

reverse_uint8_slice_c

void reverse_uint8_slice_c( cVarUint8Slice slice );

Via the macro REVERSE_C_ implemented function.

rotate_uint8_slice_c

void rotate_uint8_slice_c( cVarUint8Slice slice, int64_t distance );

Via the macro ROTATE_C_ implemented function.

sum_uint8_c

bool sum_uint8_c( cUint8Slice slice, uint64_t res[static 1] );

Builds the sum of all values in the slice and saves the result in res. Returns false if a overflow occures, otherwise true.