当前位置: 首页>>代码示例>>C++>>正文


C++ compact函数代码示例

本文整理汇总了C++中compact函数的典型用法代码示例。如果您正苦于以下问题:C++ compact函数的具体用法?C++ compact怎么用?C++ compact使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了compact函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: grpc_chttp2_stream_map_move_into

void grpc_chttp2_stream_map_move_into(grpc_chttp2_stream_map *src,
                                      grpc_chttp2_stream_map *dst) {
  /* if src is empty we dont need to do anything */
  if (src->count == src->free) {
    return;
  }
  /* if dst is empty we simply need to swap */
  if (dst->count == dst->free) {
    GPR_SWAP(grpc_chttp2_stream_map, *src, *dst);
    return;
  }
  /* the first element of src must be greater than the last of dst...
   * however the maps may need compacting for this property to hold */
  if (src->keys[0] <= dst->keys[dst->count - 1]) {
    src->count = compact(src->keys, src->values, src->count);
    src->free = 0;
    dst->count = compact(dst->keys, dst->values, dst->count);
    dst->free = 0;
  }
  GPR_ASSERT(src->keys[0] > dst->keys[dst->count - 1]);
  /* if dst doesn't have capacity, resize */
  if (dst->count + src->count > dst->capacity) {
    dst->capacity = GPR_MAX(dst->capacity * 3 / 2, dst->count + src->count);
    dst->keys = gpr_realloc(dst->keys, dst->capacity * sizeof(uint32_t));
    dst->values = gpr_realloc(dst->values, dst->capacity * sizeof(void *));
  }
  memcpy(dst->keys + dst->count, src->keys, src->count * sizeof(uint32_t));
  memcpy(dst->values + dst->count, src->values, src->count * sizeof(void *));
  dst->count += src->count;
  dst->free += src->free;
  src->count = 0;
  src->free = 0;
}
开发者ID:AlexTalks,项目名称:bazel,代码行数:33,代码来源:stream_map.c

示例2: join_leaf

static int join_leaf (
	tree_s 		*tree,
	branch_s	*parent,
	leaf_s		*child,
	int		k)
{
	leaf_s	*sibling;

	sibling = bget(tree->t_dev, parent->br_key[k+1].k_block);
	if (!sibling) return qERR_NOT_FOUND;

	if (child->l_total + sibling->l_total > MAX_FREE) {
FN;
		compact(child);
		compact(sibling);
		copy_recs(child, sibling, 0);
		memmove( &parent->br_key[k+1], &parent->br_key[k+2],
			sizeof(parent->br_key[0]) * (parent->br_num - (k+2)));
		--parent->br_num;
		bdirty(parent);
	}
	//verify_leaf(child, WHERE);
	bput(sibling);	// Should free sibling
	return 0;
}
开发者ID:taysom,项目名称:tau,代码行数:25,代码来源:btree.c

示例3: f_compact

Array f_compact(int _argc, CVarRef varname, CArrRef _argv /* = null_array */) {
  Array ret = Array::Create();
  HPHP::VM::VarEnv* v = g_vmContext->getVarEnv();
  if (v) {
    compact(v, ret, varname);
    compact(v, ret, _argv);
  }
  return ret;
}
开发者ID:SagaieNet,项目名称:hiphop-php,代码行数:9,代码来源:ext_array.cpp

示例4: garbage_collect

void garbage_collect()
{
	mark_all_cells();
	unmark_cells(all_symbols, all_symbols, 0);
	unmark_cells(top_env, top_env, 0);
	reclaim_marked();
	update_remaining();
	compact(all_symbols);
	compact(top_env);
	top_allocated = NULL;
}
开发者ID:oriansj,项目名称:stage0,代码行数:11,代码来源:lisp_cell.c

示例5: grpc_chttp2_stream_map_add

void grpc_chttp2_stream_map_add(grpc_chttp2_stream_map *map, uint32_t key,
                                void *value) {
  size_t count = map->count;
  size_t capacity = map->capacity;
  uint32_t *keys = map->keys;
  void **values = map->values;

  GPR_ASSERT(count == 0 || keys[count - 1] < key);
  GPR_ASSERT(value);
  GPR_ASSERT(grpc_chttp2_stream_map_find(map, key) == NULL);

  if (count == capacity) {
    if (map->free > capacity / 4) {
      count = compact(keys, values, count);
      map->free = 0;
    } else {
      /* resize when less than 25% of the table is free, because compaction
         won't help much */
      map->capacity = capacity = 3 * capacity / 2;
      map->keys = keys = gpr_realloc(keys, capacity * sizeof(uint32_t));
      map->values = values = gpr_realloc(values, capacity * sizeof(void *));
    }
  }

  keys[count] = key;
  values[count] = value;
  map->count = count + 1;
}
开发者ID:andrewpollock,项目名称:grpc,代码行数:28,代码来源:stream_map.c

示例6: main

int main() {
    read();
    sort();
    compact();
    write();
    return 0;
}
开发者ID:citrit,项目名称:ECSE4750,代码行数:7,代码来源:P4.C

示例7: while

int CStreamBuffer::write( int sd, int flag )
{
	int res = 0;
	char* p = m_buffer + m_offset;
	size_t len = m_used - m_offset;
	while( len > 0 ){
		WRAP_SYSCALL( res, send( sd, p, len, flag ) );
		if( res < 0 ){
			if( errno == EAGAIN ||
				errno == EWOULDBLOCK ){
				perror( "not ready yet" );
				return ERR_SEND_FAILED;
			}
			else{
				perror( "couldn't send" );
				return -1;
			}
		}
		len -= res;
		p += res;
		m_offset += res;
	}
	compact( m_offset );
	return 0;
}
开发者ID:utahta,项目名称:sendbuffer-overflow,代码行数:25,代码来源:stream_buffer.cpp

示例8: while

// compact: compact repeat instructions
static instruction *compact (instruction *prog) {
    instruction *ret = prog;
    register char flag1 = 0, flag2 = 0;

    while (prog) {
        switch ((int) prog->opcode) {
            case LOOP_START:
                prog->loop = compact(prog->loop);
                break;
            case INC:
            case DEC:
            case NEXT:
            case PREV:
                flag1 = flag2 = 0;
                while (prog->next && (flag1 = same(prog) || (flag2 = another(prog)))) {
                    instruction *t = prog->next;
                    prog->value += flag1 && !flag2 ? t->value : -t->value;
                    prog->next = t->next;
                    free(t);
                }
                break;
        }
        prog = prog->next;
    }
    return ret;
}
开发者ID:xatier,项目名称:brainfuck-tools,代码行数:27,代码来源:int.c

示例9: CAST_PTR

void i4_horizontal_compact_window_class::receive_event(i4_event * ev)
{
	if (ev->type()==i4_event::WINDOW_MESSAGE)
	{
		CAST_PTR(mess,i4_window_message_class,ev);

		if (mess->sub_type==i4_window_message_class::NOTIFY_RESIZE)
		{
			CAST_PTR(res,i4_window_notify_resize_class,ev);
			sw32 ow=res->from()->width(), oh=res->from()->height();
			res->from()->private_resize(res->new_width, res->new_height);
			compact();
			res->from()->private_resize(ow, oh);
			note_undrawn(0,0, width()-1, height()-1);
		}
		else
		{
			i4_parent_window_class::receive_event(ev);
		}
	}
	else
	{
		i4_parent_window_class::receive_event(ev);
	}
}
开发者ID:pgrawehr,项目名称:golgotha,代码行数:25,代码来源:gui__browse_tree.cpp

示例10: compact

void Server::aggregate (const std::string & survey_in)
{
    Structure survey;
    survey.load(survey_in);
    if (POMAGMA_DEBUG_LEVEL > 1) {
        survey.validate();
    }
    compact(m_structure);
    if (POMAGMA_DEBUG_LEVEL > 1) {
        m_structure.validate();
    }
    DenseSet defined = restricted(survey.signature(), m_structure.signature());
    size_t total_dim =
        m_structure.carrier().item_count() + defined.count_items();
    if (m_structure.carrier().item_dim() < total_dim) {
        m_structure.resize(total_dim);
        if (POMAGMA_DEBUG_LEVEL > 1) {
            m_structure.validate();
        }
    }
    pomagma::aggregate(m_structure, survey, defined);
    if (POMAGMA_DEBUG_LEVEL > 1) {
        m_structure.validate();
    }
}
开发者ID:imclab,项目名称:pomagma,代码行数:25,代码来源:server.cpp

示例11: try_compact

void try_compact() {
    if (arena != 0 && freemem != 0) {
        struct myinfo stat = myinfo();
        double fragm = ((double)(stat.freemem - stat.maxfreeblk) * 100) / stat.freemem;
        if (fragm > 70) compact();
    }
}
开发者ID:EvaGL,项目名称:malloc,代码行数:7,代码来源:selfcompact.cpp

示例12: main

int main(){

	std::cout<<"main started mmStart"<<&M<<std::endl;
	assert0(chdir("/home/gk/Dropbox/workspace01/napl22")==0,"unable to change dir");
	stopETs.store(false,0);
	ETs.reserve(0x100);
	compact(M);
#if true
	int fin,i;
	if(	(fin=open("naplStart0.napl",0,S_IRUSR))>=0){
		i=startET(fin,dup(fileno(stdout)));
	}
	while(!ETs[i].threadEnded){}
	if(ETs[i].joinable()) 
		ETs[i].join();
#endif
	HandleIncomingConnections(8000); 

		for(size_t i=0;i<ETs.size();i++){
			std::cout<<"ETs["<<i<<"] threadEnded="<<ETs[i].threadEnded<<" joinable="<<ETs[i].joinable()<<std::endl;
			if(ETs[i].joinable()) ETs[i].join();
		}

		for(size_t i=0;i<ETs.size();i++){
			std::cout<<"ETs["<<i<<"] threadEnded="<<ETs[i].threadEnded<<" joinable="<<ETs[i].joinable()<<std::endl;
		}

		return 0;
}
开发者ID:gkourtis,项目名称:napl3,代码行数:29,代码来源:main.cpp

示例13: MA_compact

void MA_compact(void) 
{ 
	MemBlk *mb; 
	Header *fh, *mfh = NULL; 
	int i; 

	ENTERCRITICALSECTION(CS); 

	for (mb=MMBP ; mb ; mb = mb->next) { 
		fh = compact(mb); 
		if (fh) { 
			fh->next = mfh; 
			mfh = fh; 
		} 
	} 


	for (i=0 ; Map[i].userBytes ; ++i) 
		Map[i].h = NULL; 


	while (fh = mfh) { 
		mfh = fh->next; 
		fh->status = 'U'; 
		fh->next = NULL; 
		MA_free(fh+1); 
	} 
	LEAVECRITICALSECTION(CS); 
} 
开发者ID:blakemcbride,项目名称:Dynace,代码行数:29,代码来源:memalloc.c

示例14: compact

void Server::trim(const std::vector<TrimTask>& tasks) {
    compact(m_structure);
    const size_t item_count = m_structure.carrier().item_count();

    std::vector<TrimTask> sorted_tasks = tasks;
    std::sort(sorted_tasks.begin(), sorted_tasks.end(),
              [](const TrimTask& lhs,
                 const TrimTask& rhs) { return lhs.size > rhs.size; });
    const size_t task_count = sorted_tasks.size();
#pragma omp parallel for schedule(dynamic, 1)
    for (size_t iter = 0; iter < task_count; ++iter) {
        const TrimTask& task = sorted_tasks[iter];
        if (task.size >= item_count) {
            if (task.size > item_count) {
                POMAGMA_WARN("trimming only " << item_count << " of "
                                              << task.size << " obs");
            }
            m_structure.dump(task.filename);

        } else {
            Structure region;
            region.init_carrier(task.size);
            extend(region.signature(), m_structure.signature());
            pomagma::trim(m_structure, region, m_theory_file, m_language_file,
                          task.temperature);
            if (POMAGMA_DEBUG_LEVEL > 1) {
                region.validate();
            }
            region.dump(task.filename);
        }
    }
}
开发者ID:fritzo,项目名称:pomagma,代码行数:32,代码来源:server.cpp

示例15: repOK

/*
 * Remove -- remove an entry from this node
 *
 * 
 */
void 
indexNode::remove(void *key, bSize_t len) {

  repOK();
  TOUCH();

  //find the index of the record corresponding to key
  int i=0;
  while ( (i < header->numElems) && (tree->comparisonFunction(key, len, nth_key(i),
							      nth_keyLen(i))) ) i++;
  if (i == header->numElems) {
    warn("attempt to delete non-existent element (indexNode)");
    exit(1);
  }

  //shuffle the localPointers
  for (int j = i; j < header->numElems - 1; j++) 
    header->localPointers[j] = header->localPointers[j+1];

  header->numElems--;

  repOK();
  compact();
  return;
}
开发者ID:bougyman,项目名称:sfs,代码行数:30,代码来源:indexNode.C


注:本文中的compact函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。