int8
Overview
Module with functions and types to work with int8_t values.
Types and Definitions
Generated
cInt8Slice
struct cInt8Slice { int64_t s; int8_t const* v; }; typedef struct cInt8Slice cInt8Slice;
Via the macros SLICE_DEF_C_ and SLICE_IMPL_C_ declared and implemented struct. The macros declare and implement also the following functions.
/* init */ cInt8Slice int8_slice_c( int64_t s, int8_t const* v ); cInt8Slice make_int8_slice_c( int8_t const* beg, int8_t const* end ); cInt8Slice empty_int8_slice_c( void ); /* sub */ cInt8Slice left_int8_slice_c( cInt8Slice slice, int64_t maxLen ); cInt8Slice mid_int8_slice_c( cInt8Slice slice, int64_t index ); cInt8Slice right_int8_slice_c( cInt8Slice slice, int64_t maxLen ); cInt8Slice sub_int8_slice_c( cInt8Slice slice, int64_t begIdx, int64_t endIdx );
cVarInt8Slice
struct cVarInt8Slice { int64_t s; int8_t* v; }; typedef struct cVarInt8Slice cVarInt8Slice;
Via the macros SLICE_DEF_C_ and SLICE_IMPL_C_ declared and implemented struct. The macros declare and implement also the following functions.
/* init */ cVarInt8Slice var_int8_slice_c( int64_t s, int8_t const* v ); cVarInt8Slice make_var_int8_slice_c( int8_t* beg, int8_t* end ); cVarInt8Slice empty_var_int8_slice_c( void ); /* sub */ cVarInt8Slice left_var_int8_slice_c( cVarInt8Slice slice, int64_t maxLen ); cVarInt8Slice mid_var_int8_slice_c( cVarInt8Slice slice, int64_t index ); cVarInt8Slice right_var_int8_slice_c( cVarInt8Slice slice, int64_t maxLen ); cVarInt8Slice sub_var_int8_slice_c( cVarInt8Slice slice, int64_t begIdx, int64_t endIdx ); /* var slice */ cInt8Slice as_int8_slice_c( cVarInt8Slice slice ); cVarInt8Slice cast_int8_slice_c( cVarInt8Slice slice, cInt8Slice sub ); int64_t set_int8_slice_c( cVarInt8Slice dst, cInt8Slice src );
cInt8Chunk
struct cInt8Chunk { int64_t s; int8_t const* v; int64_t favSize; cInt8Slice slice; }; typedef struct cInt8Chunk cInt8Chunk;
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_int8_chunk_c( cInt8Chunk chunk[static 1], int64_t s, cInt8Slice slice ); void init_front_int8_chunk_c( cInt8Chunk chunk[static 1], int64_t s, cInt8Slice slice );
cVarInt8Chunk
struct cVarInt8Chunk { int64_t s; int8_t* v; int64_t favSize; cInt8Slice slice; }; typedef struct cVarInt8Chunk cVarInt8Chunk;
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_int8_chunk_c( cVarInt8Chunk chunk[static 1], int64_t s, cVarInt8Slice slice ); void init_front_var_int8_chunk_c( cVarInt8Chunk chunk[static 1], int64_t s, cVarInt8Slice slice );
cInt8Window
struct cInt8Window { int64_t s; int8_t const* v; int64_t favSize; cInt8Slice slice; }; typedef struct cInt8Window cInt8Window;
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_int8_window_c( cInt8Window window[static 1], int64_t s, cInt8Slice slice ); void init_front_int8_window_c( cInt8Window window[static 1], int64_t s, cInt8Slice slice );
cVarInt8Window
struct cVarInt8Window { int64_t s; int8_t* v; int64_t favSize; cVarInt8Slice slice; }; typedef struct cVarInt8Window cVarInt8Window;
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_int8_window_c( cVarInt8Window window[static 1], int64_t s, cVarInt8Slice slice ); void init_front_var_int8_window_c( cVarInt8Window window[static 1], int64_t s, cVarInt8Slice slice );
Functions
overall
cmp_int8_c
int cmp_int8_c( int8_t a, int8_t b );
Compares two int8_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
#include "clingo/lang/expect.h" #include "clingo/type/int8.h" int main( void ) { init_tap_c_(); expect_lt_c_( cmp_int8_c( -128, 0 ) ); expect_lt_c_( cmp_int8_c( -1, 0 ) ); expect_eq_c_( cmp_int8_c( 0, 0 ) ); expect_gt_c_( cmp_int8_c( 1, 0 ) ); expect_gt_c_( cmp_int8_c( 127, 0 ) ); return finish_tap_c_(); }
int8_c_
#define int8_c_( Value )
Macro function that casts the Value as int8_t.
conv
int64_to_int8_c
bool int64_to_int8_c( int64_t src, int8_t dst[static 1] );
Via the macro CONV_C_ implemented function. Returns true if the int64_t value can be represented in a int8_t variable, otherwise false.
#include "clingo/lang/expect.h" #include "clingo/type/int8.h" int main( void ) { init_tap_c_(); int8_t i8 = 0; // ------------------------------------------------------------ max - int64_t int64_t i64 = 127; // INT8_MAX expect_c_( int64_to_int8_c( i64, &i8 ) ); expect_c_( i8 == 127 ); ++i64; // 128 expect_c_( not int64_to_int8_c( i64, &i8 ) ); // ------------------------------------------------------------ min - int16_t int16_t i16 = -128; // INT8_MIN expect_c_( int64_to_int8_c( i16, &i8 ) ); expect_c_( i8 == -128 ); --i16; // -129 expect_c_( not int64_to_int8_c( i16, &i8 ) ); return finish_tap_c_(); }
uint64_to_int8_c
bool uint64_to_int8_c( uint64_t src, int8_t dst[static 1] );
Via the macro CONV_C_ implemented function. Returns true if the uint64_t value can be represented in a int8_t variable, otherwise false.
#include "clingo/lang/expect.h" #include "clingo/type/int8.h" int main( void ) { init_tap_c_(); int8_t i8 = 0; // ----------------------------------------------------------------- uint64_t uint64_t u64 = 127; // INT8_MAX expect_c_( uint64_to_int8_c( u64, &i8 ) ); expect_c_( i8 == 127 ); ++u64; // 128 expect_c_( not uint64_to_int8_c( u64, &i8 ) ); return finish_tap_c_(); }
algo
cmp_int8_slice_c
int64_t cmp_int8_slice_c( cInt8Slice a, cInt8Slice b );
Via the macro CMP_SLICE_C_ implemented function.
count_eq_int8_c
int64_t count_eq_int8_c( cInt8Slice slice, int8_t val );
Via the macro COUNT_EQ_C_ implemented function.
find_int8_c
int8_t const* find_int8_c( cInt8Slice slice, int8_t val );
Via the macro FIND_VAL_C_ implemented function.
max_int8_c
int8_t const* max_int8_c( cInt8Slice slice );
Via the macro FIND_MAX_C_ implemented function.
min_int8_c
int8_t const* min_int8_c( cInt8Slice slice );
Via the macro FIND_MIN_C_ implemented function.
prod_int8_c
bool prod_int8_c( cInt8Slice slice, int64_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_int8_slice_c
void qsort_int8_slice_c( cVarInt8Slice slice );
Via the macro QSORT_C_ implemented function.
reverse_int8_slice_c
void reverse_int8_slice_c( cVarInt8Slice slice );
Via the macro REVERSE_C_ implemented function.
rotate_int8_slice_c
void rotate_var_int8_slice_c( cVarInt8Slice slice, int64_t distance );
Via the macro ROTATE_C_ implemented function.
sum_int8_c
bool sum_int8_c( cInt8Slice slice, int64_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.