bool

Overview

Module with functions and types to work with bool values.

Types and Definitions

Generated

cBoolSlice

struct cBoolSlice
{
   int64_t s;
   bool const* v;
};
typedef struct cBoolSlice cBoolSlice;

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

/* init */
cBoolSlice bool_slice_c( int64_t s, bool const* v );
cBoolSlice make_bool_slice_c( bool const* beg, bool const* end );
cBoolSlice empty_bool_slice_c( void );
/* sub */
cBoolSlice left_bool_slice_c( cBoolSlice slice, int64_t maxLen );
cBoolSlice mid_bool_slice_c( cBoolSlice slice, int64_t index );
cBoolSlice right_bool_slice_c( cBoolSlice slice, int64_t maxLen );
cBoolSlice sub_bool_slice_c( cBoolSlice slice, int64_t begIdx, int64_t endIdx );

cVarBoolSlice

struct cVarBoolSlice
{
   int64_t s;
   bool* v;
};
typedef struct cVarBoolSlice cVarBoolSlice;

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

/* init */
cVarBoolSlice var_bool_slice_c( int64_t s, bool* v );
cVarBoolSlice make_var_bool_slice_c( bool* beg, bool* end );
cVarBoolSlice empty_var_bool_slice_c( void );
/* sub */
cVarBoolSlice left_var_bool_slice_c( cVarBoolSlice slice, int64_t maxLen );
cVarBoolSlice mid_var_bool_slice_c( cVarBoolSlice slice, int64_t index );
cVarBoolSlice right_var_bool_slice_c( cVarBoolSlice slice, int64_t maxLen );
cVarBoolSlice sub_var_bool_slice_c( cVarBoolSlice slice,
                                    int64_t begIdx,
                                    int64_t endIdx );
/* var slice */
cBoolSlice as_bool_slice_c( cVarBoolSlice slice );
cVarBoolSlice cast_bool_slice_c( cVarBoolSlice slice, cBoolSlice sub );
int64_t set_bool_slice_c( cVarBoolSlice dst, cBoolSlice src );

cBoolChunk

struct cBoolChunk
{
   int64_t s;
   bool const* v;
   int64_t favSize;
   cBoolSlice slice;
};
typedef struct cBoolChunk cBoolChunk;

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_bool_chunk_c( cBoolChunk chunk[static 1],
                             int64_t s,
                             cBoolSlice slice );
void init_front_bool_chunk_c( cBoolChunk chunk[static 1],
                              int64_t s,
                              cBoolSlice slice );

cVarBoolChunk

struct cVarBoolChunk
{
   int64_t s;
   bool* v;
   int64_t favSize;
   cVarBoolSlice slice;
};
typedef struct cVarBoolChunk cVarBoolChunk;

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_bool_chunk_c( cVarBoolChunk chunk[static 1],
                                 int64_t s,
                                 cVarBoolSlice slice );
void init_front_var_bool_chunk_c( cVarBoolChunk chunk[static 1],
                                  int64_t s,
                                  cVarBoolSlice slice );

cBoolWindow

struct cBoolWindow
{
   int64_t s;
   bool const* v;
   cBoolSlice slice;
};
typedef struct cBoolWindow cBoolWindow;

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_bool_window_c( cBoolWindow window[static 1],
                              int64_t s,
                              cBoolSlice slice );
void init_front_bool_window_c( cBoolWindow window[static 1],
                               int64_t s,
                               cBoolSlice slice );

cVarBoolWindow

struct cVarBoolWindow
{
   int64_t s;
   bool* v;
   cVarBoolSlice slice;
};
typedef struct cVarBoolWindow cVarBoolWindow;

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_bool_window_c( cVarBoolWindow window[static 1],
                                  int64_t s,
                                  cVarBoolSlice slice );
void init_front_var_bool_window_c( cVarBoolWindow window[static 1],
                                   int64_t s,
                                   cVarBoolSlice slice );

Functions

overall

bool_c_

#define bool_c_( Value )

Macro function that casts the Value as bool.

cmp_bool_c

int cmp_bool_c( bool a, bool b );

Compares two bool 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/bool.h"

int main( void )
{
   init_tap_c_();

   expect_lt_c_( cmp_bool_c( false,  true ) );
   expect_eq_c_( cmp_bool_c( false, false ) );
   expect_eq_c_( cmp_bool_c(  true,  true ) );
   expect_gt_c_( cmp_bool_c(  true, false ) );

   return finish_tap_c_();
}

algo

and_bool_slice_values_c

bool and_bool_slice_values_c( cBoolSlice slice );

Combines all values in the slice with a logical and operation.

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

int main( void )
{
   init_tap_c_();

   cBoolSlice s000 = slice_c_( bool, false, false, false );
   cBoolSlice s001 = slice_c_( bool, false, false,  true );
   cBoolSlice s010 = slice_c_( bool, false,  true, false );
   cBoolSlice s011 = slice_c_( bool, false,  true,  true );
   cBoolSlice s100 = slice_c_( bool,  true, false, false );
   cBoolSlice s101 = slice_c_( bool,  true, false,  true );
   cBoolSlice s110 = slice_c_( bool,  true,  true, false );
   cBoolSlice s111 = slice_c_( bool,  true,  true,  true );

   expect_c_( not and_bool_slice_values_c( s000 ) );
   expect_c_( not and_bool_slice_values_c( s001 ) );
   expect_c_( not and_bool_slice_values_c( s010 ) );
   expect_c_( not and_bool_slice_values_c( s011 ) );
   expect_c_( not and_bool_slice_values_c( s100 ) );
   expect_c_( not and_bool_slice_values_c( s101 ) );
   expect_c_( not and_bool_slice_values_c( s110 ) );
   expect_c_(     and_bool_slice_values_c( s111 ) );

   return finish_tap_c_();
}

count_eq_bool_c

int64_t count_eq_bool_c( cBoolSlice slice, bool val );

Via the macro COUNT_EQ_C_ implemented function.

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

int main( void )
{
   init_tap_c_();

   cBoolSlice s01010 = slice_c_( bool, false, true, false, true, false );

   expect_c_( count_eq_bool_c( s01010, true  ) == 2 );
   expect_c_( count_eq_bool_c( s01010, false ) == 3 );

   return finish_tap_c_();
}

or_bool_slice_values_c

bool or_bool_slice_values_c( cBoolSlice slice );

Combines all values in the slice with a logical or operation.

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

int main( void )
{
   init_tap_c_();

   cBoolSlice s000 = slice_c_( bool, false, false, false );
   cBoolSlice s001 = slice_c_( bool, false, false,  true );
   cBoolSlice s010 = slice_c_( bool, false,  true, false );
   cBoolSlice s011 = slice_c_( bool, false,  true,  true );
   cBoolSlice s100 = slice_c_( bool,  true, false, false );
   cBoolSlice s101 = slice_c_( bool,  true, false,  true );
   cBoolSlice s110 = slice_c_( bool,  true,  true, false );
   cBoolSlice s111 = slice_c_( bool,  true,  true,  true );

   expect_c_( not or_bool_slice_values_c( s000 ) );
   expect_c_( or_bool_slice_values_c( s001 ) );
   expect_c_( or_bool_slice_values_c( s010 ) );
   expect_c_( or_bool_slice_values_c( s011 ) );
   expect_c_( or_bool_slice_values_c( s100 ) );
   expect_c_( or_bool_slice_values_c( s101 ) );
   expect_c_( or_bool_slice_values_c( s110 ) );
   expect_c_( or_bool_slice_values_c( s111 ) );

   return finish_tap_c_();
}