本文整理汇总了C++中set_val函数的典型用法代码示例。如果您正苦于以下问题:C++ set_val函数的具体用法?C++ set_val怎么用?C++ set_val使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了set_val函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: set_ptr
/*
* Set the pred and succ of the given free block
* Since the whole memory space is 2^32 bytes
* I can compress the 8 bytes address into 4 bytes
* by computing its offest to heap_listp
*/
static inline void set_ptr(uint32_t* const block,
uint32_t* const pred_block,
uint32_t* const succ_block) {
REQUIRES(block != NULL);
REQUIRES(in_heap(block));
unsigned int pred_offest;
unsigned int succ_offest;
if (pred_block == NULL)
pred_offest = 0;
else
pred_offest = pred_block - heap_listp;
if (succ_block == NULL)
succ_offest = 0;
else
succ_offest = succ_block - heap_listp;
//printf("pred_off = %d, succ_off = %d\n", pred_offest, succ_offest);
set_val(block + 1 , pred_offest);
set_val(block + 2 , succ_offest);
ENSURES(block_pred(block) == pred_block);
ENSURES(block_succ(block) == succ_block);
}
示例2: lean_assert
template <typename T, typename X> void permutation_matrix<T, X>::transpose_from_right(unsigned i, unsigned j) {
// the result will be this = this * (i,j)
lean_assert(i < size() && j < size() && i != j);
auto pi = m_permutation[i];
auto pj = m_permutation[j];
set_val(i, pj);
set_val(j, pi);
}
示例3: alloc_body
inline body_type * alloc_body(std::size_t capacity, const char * first, std::size_t len)
{
auto * body = alloc_body<body_type>(capacity);
set_val(body->capacity, capacity);
set_val(body->size, len);
std::memcpy(body->buffer, first, len);
return body;
}
示例4: alloc_body_nothrow
inline body_type * alloc_body_nothrow(std::size_t capacity, const char * first, std::size_t len)
{
auto * body = alloc_body_nothrow<body_type>(capacity);
if (body == nullptr) return nullptr;
set_val(body->capacity, capacity);
set_val(body->size, len);
std::memcpy(body->buffer, first, len);
return body;
}
示例5: realloc_body
inline typename std::enable_if<std::is_same<body_type, other_body_type>::value, body_type>::type *
realloc_body(other_body_type * other, std::size_t newcap)
{
auto * body = static_cast<body_type *>(::realloc(other, sizeof(body_type) + newcap));
if (body == nullptr) throw std::bad_alloc();
set_val(body->capacity, newcap);
if (body->size > newcap) set_val(body->size, newcap);
return body;
}
示例6: set_val
void Range::set_unit_value(double p_value) {
if (shared->exp_unit_value && get_min()>0) {
double exp_min = Math::log(get_min())/Math::log(2);
double exp_max = Math::log(get_max())/Math::log(2);
double v = Math::pow(2,exp_min+(exp_max-exp_min)*p_value);
set_val( v );
} else {
set_val( (get_max() - get_min()) * p_value + get_min() );
}
}
示例7: realloc_body_nothrow
inline typename std::enable_if< ! std::is_same<body_type, other_body_type>::value, body_type>::type *
realloc_body_nothrow(other_body_type * other, std::size_t newcap)
{
std::size_t size = std::min<std::size_t>(other->size, newcap);
auto * body = static_cast<body_type *>(::realloc(other, sizeof(body_type) + newcap));
if (body == nullptr) return nullptr;
std::memmove(body->buffer, other->buffer, size);
set_val(body->size, size);
set_val(body->capacity, newcap);
return body;
}
示例8: env_update_cb
/*
* Update callback function
* db: the database
* key: key dbt of the kv pair
* old_val: old_val of the key dbt, if its null, we must create val
* extra: the struct we pass to db->update function
* set_val: set value function, should be provided by tokudb
* set_extra: argument for set_val callback
*/
static int
env_update_cb(DB *db, const DBT *key, const DBT *old_val, const DBT *extra,
void (*set_val)(const DBT *newval, void *set_extra),
void *set_extra)
{
int ret;
DBT val;
size_t newval_size;
void *newval;
BUG_ON(db == NULL || key == NULL || extra == NULL ||
extra->data == NULL);
// there is no meta update currently
BUG_ON(IS_META_KEY_DBT(key));
ret = block_update_cb(&newval, &newval_size, old_val, extra->data);
if (!ret) {
dbt_init(&val, newval, newval_size);
set_val(&val, set_extra);
kfree(newval);
}
return ret;
}
示例9: set_val
JNIEXPORT jint JNICALL Java_edu_berkeley_bid_CUMAT_setval
(JNIEnv *env, jobject obj, jobject jA, jfloat vv, jint length)
{
float *nativeA = (float*)getPointer(env, jA);
return set_val(nativeA, vv, length);
}
示例10: auryn_vector_float_clip
void IF2Group::check_thresholds()
{
auryn_vector_float_clip( mem, e_rev );
AurynState * thr_ptr = thr->data;
for ( AurynState * i = mem->data ; i != mem->data+get_rank_size() ; ++i ) { // it's important to use rank_size here otherwise there might be spikes from units that do not exist
if ( *i > ( thr_rest + *thr_ptr ) ) {
NeuronID unit = i-mem->data;
push_spike(unit);
set_val (mem, unit, e_rest); // reset
set_val (thr, unit, dthr); //refractory
}
thr_ptr++;
}
}
示例11: exec_step_dovr
int exec_step_dovr(struct band_list_el *bll){
unsigned char *adrs;
long double val;
void *ptr;
int tip, size, artsin, sayqac;
tip = bll->tip;
size = bll->size;
ptr = pop_from_stek(&adrstk);
adrs = (unsigned char *)ptr;
val = get_value(adrs, tip, size);
sayqac = (int)val;
/* !!! do not free ptr popped from adrstk */
ptr = pop_from_stek(&valstk);
val = *(long double *)ptr;
artsin = (int)val;
free(ptr);
if (artsin)
sayqac++;
else
sayqac--;
val = (long double)sayqac;
set_val(adrs, val, tip);
return bll->head_pos;
}
示例12: set_val
JNIEXPORT jint JNICALL Java_edu_berkeley_bid_CUMATD_setval
(JNIEnv *env, jobject obj, jobject jA, jdouble vv, jint length)
{
double *nativeA = (double*)getPointer(env, jA);
return set_val(nativeA, vv, length);
}
示例13: set_size
// Set the size of the given block in multiples of 4 bytes
static inline void set_size(uint32_t* const block, unsigned int size) {
REQUIRES(block != NULL);
REQUIRES(in_heap(block));
REQUIRES(size % 2 == 0);
set_val(block, size);
}
示例14: clone_m_permutation
template <typename T, typename X> void permutation_matrix<T, X>::multiply_by_reverse_from_right(permutation_matrix<T, X> & q){ // todo : condensed permutations ?
auto clone = clone_m_permutation();
// the result is this = this*q(-1)
unsigned i = size();
while (i-- > 0) {
set_val(i, q.m_rev[clone[i]]); // we have m(P)*m(Q) = m(QP), where m is the matrix of the permutation
}
delete [] clone;
}
示例15: SetValGTM
/*
* Set values for sequence
*/
int
SetValGTM(char *seqname, GTM_Sequence nextval, bool iscalled)
{
GTM_SequenceKeyData seqkey;
#ifdef XCP
char *coordName = IS_PGXC_COORDINATOR ? PGXCNodeName : MyCoordName;
int coordPid = IS_PGXC_COORDINATOR ? MyProcPid : MyCoordPid;
#endif
CheckConnection();
seqkey.gsk_keylen = strlen(seqname) + 1;
seqkey.gsk_key = seqname;
#ifdef XCP
return conn ? set_val(conn, &seqkey, coordName, coordPid, nextval, iscalled) : -1;
#else
return conn ? set_val(conn, &seqkey, nextval, iscalled) : -1;
#endif
}