本文整理汇总了C++中collect函数的典型用法代码示例。如果您正苦于以下问题:C++ collect函数的具体用法?C++ collect怎么用?C++ collect使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了collect函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: log
void
MB12XX::cycle()
{
/* collection phase? */
if (_collect_phase) {
/* perform collection */
if (OK != collect()) {
log("collection error");
/* restart the measurement state machine */
start();
return;
}
/* next phase is measurement */
_collect_phase = false;
/*
* Is there a collect->measure gap?
*/
if (_measure_ticks > USEC2TICK(MB12XX_CONVERSION_INTERVAL)) {
/* schedule a fresh cycle call when we are ready to measure again */
work_queue(HPWORK,
&_work,
(worker_t)&MB12XX::cycle_trampoline,
this,
_measure_ticks - USEC2TICK(MB12XX_CONVERSION_INTERVAL));
return;
}
}
/* measurement phase */
if (OK != measure())
log("measure error");
/* next phase is collection */
_collect_phase = true;
/* schedule a fresh cycle call when the measurement is done */
work_queue(HPWORK,
&_work,
(worker_t)&MB12XX::cycle_trampoline,
this,
USEC2TICK(MB12XX_CONVERSION_INTERVAL));
}
示例2: get_ifconfig_info
static int
get_ifconfig_info(struct net_desc *devs)
{
char *buf_in;
char *buf_tmp;
const char **ignore;
char *buf;
char *tmp;
int textsize;
int i;
/* Get ifconfig information */
textsize = collect(T_OUTPUT, &buf_in, "/sbin/ifconfig -l 2>/dev/null");
if (textsize < 0) {
if (logfp)
(void)fprintf(logfp,
"Aborting: Could not run ifconfig.\n");
(void)fprintf(stderr, "Could not run ifconfig.");
exit(1);
}
buf = malloc (STRSIZE * sizeof(char));
for (i = 0, buf_tmp = buf_in; strlen(buf_tmp) > 0 && buf_tmp < buf_in +
strlen(buf_in);) {
tmp = stpncpy(buf, buf_tmp, strcspn(buf_tmp," \n"));
*tmp='\0';
buf_tmp += (strcspn(buf_tmp, " \n") + 1) * sizeof(char);
/* Skip ignored interfaces */
for (ignore = ignored_if_names; *ignore != NULL; ignore++) {
size_t len = strlen(*ignore);
if (strncmp(buf, *ignore, len) == 0 &&
isdigit((unsigned char)buf[len]))
break;
}
if (*ignore != NULL)
continue;
strlcpy (devs[i].if_dev, buf, STRSIZE);
i++;
}
strcpy(devs[i].if_dev, "\0");
free(buf);
free(buf_in);
return i;
}
示例3: load
void ResourceConverter::convert()
{
for (auto file : listResources(m_resourceRoot
, textureDir
, textureExtension)) {
load(textureDir, file, textureExtension);
}
for (auto file : listResources(m_resourceRoot
, mmlDir
, mmlExtension)) {
load(mmlDir, file, mmlExtension);
}
collect();
compress();
encrypt();
write();
}
示例4: collect_generations
static long
collect_generations(void)
{
int i;
long n = 0;
/* Find the oldest generation (higest numbered) where the count
* exceeds the threshold. Objects in the that generation and
* generations younger than it will be collected. */
for (i = NUM_GENERATIONS-1; i >= 0; i--) {
if (generations[i].count > generations[i].threshold) {
n = collect(i);
break;
}
}
return n;
}
示例5: collect
static void collect(int *psize)
{
move_t m;
uint32 hm;
if(*psize >= MAXPLY) return;
hm = tt_get_hashmove(pos->hash);
if(hm)
{ m.p = hm;
if(make_if_legal(m))
{ pv_backup[*psize].p = hm;
*psize += 1;
collect(psize);
move_unmake();
}
}
}
示例6: collect
void collect(vector<vector<int>> mark, vector<string>& res, string s, int start, string tmp){
for(auto stop : mark[start]){
string sstr = s.substr(start, stop - start);
string newtmp = start == 0 ? sstr : tmp + " "+ sstr;
if(stop == s.length())
res.push_back(newtmp);
else collect(mark, res, s, stop, newtmp);
}
}
示例7: filtered_keys
Array* LookupTable::filtered_keys(STATE, ObjectMatcher& matcher) {
class filtered_keys : public CollectAction {
ObjectMatcher& m_;
public:
filtered_keys(ObjectMatcher& m)
: m_(m)
{}
virtual Object* call(STATE, LookupTableBucket* bucket) {
if(m_.match_p(state, bucket->key())) return bucket->key();
return 0;
}
} match(matcher);
return collect(state, this, match);
}
示例8: collect_refs
void ReachingDefinitionBase::
collect_refs ( AstInterface& fa, const AstNodePtr& h, FunctionSideEffectInterface* a,
AstInterface::AstNodeList* in)
{
for (AstInterface::AstNodeList::iterator p = in->begin();
p != in->end(); ++p) {
AstNodePtr cur = *p;
std::string varname;
AstNodePtr scope;
if (fa.IsVarRef( cur, 0, &varname, &scope))
add_ref(varname, scope, std::pair<AstNodePtr, AstNodePtr>(cur, AST_NULL) );
}
ConstructReachingDefinitionBase collect(fa, *this);
StmtSideEffectCollect op(a);
op(fa, h, &collect);
}
示例9: assert
void MemoryManager::sweep() {
assert(!sweeping());
if (debug) checkHeap();
collect("MM::sweep");
m_sweeping = true;
SCOPE_EXIT { m_sweeping = false; };
DEBUG_ONLY size_t num_sweepables = 0, num_natives = 0;
// iterate until both sweep lists are empty. Entries can be added or
// removed from either list during sweeping.
do {
while (!m_sweepables.empty()) {
num_sweepables++;
auto obj = m_sweepables.next();
obj->unregister();
obj->sweep();
}
while (!m_natives.empty()) {
num_natives++;
assert(m_natives.back()->sweep_index == m_natives.size() - 1);
auto node = m_natives.back();
m_natives.pop_back();
auto obj = Native::obj(node);
auto ndi = obj->getVMClass()->getNativeDataInfo();
ndi->sweep(obj);
// trash the native data but leave the header and object parsable
assert(memset(node+1, kSmallFreeFill, node->obj_offset - sizeof(*node)));
}
} while (!m_sweepables.empty());
DEBUG_ONLY auto napcs = m_apc_arrays.size();
FTRACE(1, "sweep: sweepable {} native {} apc array {}\n",
num_sweepables,
num_natives,
napcs);
if (debug) checkHeap();
// decref apc arrays referenced by this request. This must happen here
// (instead of in resetAllocator), because the sweep routine may use
// g_context.
while (!m_apc_arrays.empty()) {
auto a = m_apc_arrays.back();
m_apc_arrays.pop_back();
a->sweep();
}
}
示例10: sort
//排序函数
void sort(int numbers[]){
int bucket[10][SIZE] = {0}; // 定义10个桶
//每个桶第0号记录桶内数字个数
int maxDigit; // 最长几位
int i = 0;
//获得最多位数,确定排序次数
maxDigit = getMaxDigit(numbers);
//printf("maxDigit = %d\n", maxDigit);
for(i = 0; i < maxDigit; i++){
//进行第i位排序
distribute(i, bucket, numbers);
//按序归位
collect(bucket, numbers);
//debug(numbers);
}
}
示例11: collect
void PODModel::collect(){
if ( _color.a < 1 ){
return;
}
if ( _nodeIndex == (unsigned char)-1 ){
AlphaMode am;
for ( unsigned int i = 0; i < _pRes->_pod.nNumMeshNode; ++i ){
if ( _color.a < 255 ){
am = ALPHA_BLEND;
}else{
am = _pRes->getAlphaMode(i);
}
PODModelCollector::collect(this, i, am);
}
}else{
collect(_nodeIndex);
}
}
示例12: main
int main(int argc, char * argv[])
{
if (argc != 2) {printf("Please provide a matrix");}
int ierr = MPI_Init(&argc, &argv);
MPI_Comm_rank(MPI_COMM_WORLD, &rank); //sets rank
MPI_Comm_size(MPI_COMM_WORLD, &size); //gets number of processes
current_pivot = 0;
if (rank == 0) { //master process
get_number_of_rows(argv[1], &numrows);
numcols = numrows + 1; //specified by assignment
int i;
for (i = 1; i < size; i++) { //sending out information to slaves about what rows they are reading.
MPI_Isend(&numrows, 1, MPI_INT, i, MASTER_TO_SLAVE_TAG, MPI_COMM_WORLD, &request);
}
}
else {
MPI_Recv(&numrows, 1, MPI_INT, 0, MASTER_TO_SLAVE_TAG, MPI_COMM_WORLD, &status);
numcols = numrows + 1;
}
if (rank >= numrows) {
ierr = MPI_Finalize();
return 0;
} else if (rank < (numrows % size)) {
numrows = (numrows / size) + 1;
} else {
numrows = (numrows / size);
}
matrix = allocate_matrix(numrows, numcols);
read_rows(argv[1], matrix);
RREF(matrix);
absolute(matrix, &numrows, &numcols);
reduction(matrix, &numrows, &numcols);
get_best_threshold();
collect(matrix);
// print_matrix(matrix, numrows, numcols);
print_matrix(final_matrix, numcols - 1, numcols);
if (rank == 0) {
// output_to_file(final_matrix);
}
free_matrix(matrix, &numrows);
ierr = MPI_Finalize();
}
示例13: hit
HitResponse
Block::collision(GameObject& other, const CollisionHit& )
{
auto player = dynamic_cast<Player*> (&other);
if(player) {
if(player->get_bbox().get_top() > bbox.get_bottom() - SHIFT_DELTA) {
hit(*player);
}
}
// only interact with other objects if...
// 1) we are bouncing
// 2) the object is not portable (either never or not currently)
// 3) the object is being hit from below (baguys don't get killed for activating boxes)
auto portable = dynamic_cast<Portable*> (&other);
auto moving_object = dynamic_cast<MovingObject*> (&other);
auto bomb = dynamic_cast<Bomb*> (&other);
bool is_portable = ((portable != 0) && portable->is_portable());
bool is_bomb = (bomb != 0); // bombs need to explode, although they are considered portable
bool hit_mo_from_below = ((moving_object == 0) || (moving_object->get_bbox().get_bottom() < (bbox.get_top() + SHIFT_DELTA)));
if(bouncing && (!is_portable || is_bomb) && hit_mo_from_below) {
// Badguys get killed
auto badguy = dynamic_cast<BadGuy*> (&other);
if(badguy) {
badguy->kill_fall();
}
// Coins get collected
auto coin = dynamic_cast<Coin*> (&other);
if(coin) {
coin->collect();
}
//Eggs get jumped
auto growup = dynamic_cast<GrowUp*> (&other);
if(growup) {
growup->do_jump();
}
}
return FORCE_MOVE;
}
示例14: collect_and_normalize_dependencies
/* Collect (and sort) dependencies of collected parameters */
void collect_and_normalize_dependencies(buffer<expr> & norm_params) {
name_map<expr> new_types;
for (unsigned i = 0; i < m_params.size(); i++) {
expr x = m_params[i];
expr new_type = collect(m_ctx.instantiate_mvars(m_ctx.infer(x)));
new_types.insert(mlocal_name(x), new_type);
}
local_context const & lctx = m_ctx.lctx();
std::sort(m_params.begin(), m_params.end(), [&](expr const & l1, expr const & l2) {
return lctx.get_local_decl(l1)->get_idx() < lctx.get_local_decl(l2)->get_idx();
});
for (unsigned i = 0; i < m_params.size(); i++) {
expr x = m_params[i];
expr type = *new_types.find(mlocal_name(x));
expr new_type = replace_locals(type, i, m_params.data(), norm_params.data());
expr new_param = m_ctx.push_local(local_pp_name(x), new_type, local_info(x));
norm_params.push_back(new_param);
}
}
示例15: DEVICE_DEBUG
void
SF1XX::cycle()
{
/* Collect results */
if (OK != collect()) {
DEVICE_DEBUG("collection error");
/* if error restart the measurement state machine */
start();
return;
}
/* schedule a fresh cycle call when the measurement is done */
work_queue(HPWORK,
&_work,
(worker_t)&SF1XX::cycle_trampoline,
this,
USEC2TICK(_conversion_interval));
}