CInt64Vec
Overview
Module that defines the CInt64Vec type and the associated functions.
Example
#include "clingo/container/CInt64Vec.h" #include "clingo/io/cRecorder.h" #include "clingo/io/write_type.h" #include "clingo/lang/expect.h" int main( void ) { init_tap_c_(); CInt64Vec* vec = retain_c( make_int64_vec_c( 1 ) ); cVecInfo const* info = info_of_int64_vec_c( vec ); expect_c_( vec_is_empty_c( info ) ); expect_c_( info->cap == 1 ); expect_c_( info->count == 0 ); add_to_int64_vec_c( vec, 100 ); add_to_int64_vec_c( vec, 200 ); expect_c_( not vec_is_empty_c( info ) ); expect_c_( info->cap > 1 ); expect_c_( info->count == 2 ); add_many_to_int64_vec_c_( vec, 300, 400, 500 ); expect_c_( *get_from_int64_vec_c( vec, 0 ) == 100 ); expect_c_( *get_from_int64_vec_c( vec, 2 ) == 300 ); expect_c_( *get_from_int64_vec_c( vec, 4 ) == 500 ); set_on_int64_vec_c( vec, 4, 555 ); expect_c_( *get_from_int64_vec_c( vec, 4 ) == 555 ); insert_into_int64_vec_c( vec, 3, 350 ); expect_c_( info->count == 6 ); cRecorder* rec = &recorder_c_( 128 ); { cInt64Slice slice = slice_of_int64_vec_c( vec ); for_each_c_( int64_t const*, i, slice ) { write_int64_c_( rec, *i ); if ( i != rbegin_c_( slice ) ) { record_char_c( rec, ' ' ); } } } expect_c_( recorded_is_c( rec, "100 200 300 350 400 555" ) ); resize_int64_vec_c( vec, info->count ); expect_c_( info->cap == info->count ); release_all_c_( vec ); return finish_tap_c_(); }
Types and Definitions
Generated
CInt64Vec
struct CInt64Vec; typedef struct CInt64Vec CInt64Vec;
Via the macros VAL_VEC_DEF_C_ and VAL_VEC_IMPL_C_ declared and implemented struct. The macros declare and implement also the following globals and functions.
cMeta const C_Int64VecMeta; /* create */ CInt64Vec* make_int64_vec_c( int64_t cap ); CInt64Vec* new_int64_vec_c(); /* manage */ int64_t const* data_of_int64_vec_c( CInt64Vec const* vec ); cVecInfo const* info_of_int64_vec_c( CInt64Vec const* vec ); bool resize_int64_vec_c( CInt64Vec* vec, int64_t cap ); int64_t* var_data_of_int64_vec_c( CInt64Vec* vec ); /* api */ bool add_to_int64_vec_c( CInt64Vec* vec, int64_t val ); bool add_array_to_int64_vec_c( CInt64Vec* vec, int64_t n, int64_t const* arr ); int64_t const* get_from_int64_vec_c( CInt64Vec const* vec, int64_t pos ); int64_t* get_var_from_int64_vec_c( CInt64Vec* vec, int64_t pos ); bool insert_into_int64_vec_c( CInt64Vec* vec, int64_t pos, int64_t val ); bool remove_from_int64_vec_c( CInt64Vec* vec, int64_t pos ); void set_on_int64_vec_c( CInt64Vec* vec, int64_t pos, int64_t val );
overall
add_many_to_byte_vec_
#define add_many_to_int64_vec_c_( Vec, ... ) \ add_many_to_int64_vec_c( \ (Vec), (cInt64Slice)slice_c_( int64_t, __VA_ARGS__ ) \ ) bool add_many_to_int64_vec_c( CInt64Vec* vec, cInt64Slice many );
Adds all int64_t values from the slice to the int64_t vector.
slice_of_int64_vec_c
cInt64Slice slice_of_int64_vec_c( CInt64Vec const* vec );
Via the macro SLICE_OF_VEC_C_ implemented function.
var_slice_of_int64_vec_c
cVarInt64Slice var_slice_of_int64_vec_c( CInt64Vec* vec );
Via the macro VAR_SLICE_OF_VEC_C_ implemented function.