• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ place函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: remove_free_block

/**********************************************************
 * mm_malloc
 * Allocate a block of size bytes.
 * The type of search is determined by find_fit
 * The decision of splitting the block, or not is determined
 *   in place(..)
 * If no block satisfies the request, the heap is extended
 **********************************************************/
void *mm_malloc(size_t size)
{
	//mm_check();
	//print_seg(0);
//	printf("IN MALLOC\n");
    size_t asize; /* adjusted block size */
    size_t extendsize; /* amount to extend heap if no fit */
    char * bp;

    /* Ignore spurious requests */
    if (size == 0)
        return NULL;

    /* Adjust block size to include overhead and alignment reqs. */
    if (size <= DSIZE)
        asize = 2 * DSIZE;
    else
        asize = DSIZE * ((size + (DSIZE) + (DSIZE-1))/ DSIZE);

    /* Search the free list for a fit */
    if ((bp = find_segregated_best_fit(asize)) != NULL) {

    	//printf("free size found, bp is %p\n",bp);
    	remove_free_block(bp);
        place(bp, asize);
        return bp;
    };

    /* No fit found. Get more memory and place the block */
    extendsize = MAX(asize, CHUNKSIZE);
    if ((bp = extend_heap(extendsize/WSIZE)) == NULL)
    {
        return NULL;
    }
    place(bp, asize);
    return bp;

}
开发者ID:shareq2005,项目名称:Dynamic-Memory-Allocator,代码行数:46,代码来源:mm.c


示例2: dosub

void
dosub(void)
{
	Rune *lp, *sp, *rp;
	int c, n;

	lp = linebuf;
	sp = genbuf;
	rp = rhsbuf;
	while(lp < loc1)
		*sp++ = *lp++;
	while(c = *rp++) {
		if(c == '&'){
			sp = place(sp, loc1, loc2);
			continue;
		}
		if(c == ESCFLG && (c = *rp++) >= '1' && c < MAXSUB+'0') {
			n = c-'0';
			if(subexp[n].s.rsp && subexp[n].e.rep) {
				sp = place(sp, subexp[n].s.rsp, subexp[n].e.rep);
				continue;
			}
			error(Q);
		}
		*sp++ = c;
		if(sp >= &genbuf[LBSIZE])
			error(Q);
	}
	lp = loc2;
	loc2 = sp - genbuf + linebuf;
	while(*sp++ = *lp++)
		if(sp >= &genbuf[LBSIZE])
			error(Q);
	lp = linebuf;
	sp = genbuf;
	while(*lp++ = *sp++)
		;
}
开发者ID:00001,项目名称:plan9port,代码行数:38,代码来源:ed.c


示例3: mem_sbrk

/* 
 * mm_malloc - Allocate a block by incrementing the brk pointer.
 *     Always allocate a block whose size is a multiple of the alignment.
 */
void *mm_malloc(size_t size)
{
    /*int newsize = ALIGN(size + SIZE_T_SIZE);
    void *p = mem_sbrk(newsize);
    if (p == (void *)-1)
	return NULL;
    else {
        *(size_t *)p = size;
        return (void *)((char *)p + SIZE_T_SIZE);
    } */

	size_t asize;
	size_t extendsize;
	char *bp;

	//ignore spurious requests
	if(size == 0)
		return NULL;
	
	//adjust block size to include overhead and alignment reqs
	if(size <= DSIZE)
		asize = 2*DSIZE;
	else
		asize = DSIZE * ((size + (DSIZE) + (DSIZE-1)) / DSIZE);

	//search the free list for a fit
	if((bp = find_fit(asize)) != NULL) {
		place(bp, asize);
		return bp;
	}

	//no fit found, get more memory and place the block
	extendsize = MAX(asize, CHUNKSIZE);
	if((bp = extend_heap(extendsize/WSIZE)) == NULL)
		return NULL;
	place(bp, asize);
	return bp;
}
开发者ID:gillian-hyde,项目名称:Computer-Organization,代码行数:42,代码来源:mm.c


示例4: place

 void place(int *arr, int n, int k, int &count){
     if(k == n){
         ++count;
         return;
     }
     else{
         for(int i = 0; i != n; ++i){
             if(check(arr, n, k, i)){
                 arr[k] = i;
                 place(arr, n, k+1, count);
             }
         }
     }
 }
开发者ID:mengjiaowang,项目名称:leetcode,代码行数:14,代码来源:n-queens-ii.cpp


示例5: place

void scroll_label::set_label(const t_string& lbl)
{
	// Inherit.
	styled_widget::set_label(lbl);

	if(label* widget = get_internal_label()) {
		widget->set_label(lbl);

		bool resize_needed = !content_resize_request();
		if(resize_needed && get_size() != point()) {
			place(get_origin(), get_size());
		}
	}
}
开发者ID:GregoryLundberg,项目名称:wesnoth,代码行数:14,代码来源:scroll_label.cpp


示例6: if

		optional& operator=( const optional& that ) {
			if ( std::addressof( that ) == this )
				return *this;
			if ( present && that.present )
				**this = *that;
			else if ( present )
				destroy( );
			else if ( that.present )
				place( *that );
			else
				present = false;

			return *this;
		}
开发者ID:CCJY,项目名称:coliru,代码行数:14,代码来源:main.cpp


示例7: value

		optional& operator=( optional&& that ) {
			if ( std::addressof( that ) == this )
				return *this;
			if ( present && that.present )
				value( ) = std::move( that.value( ) );
			else if ( present )
				destroy( );
			else if ( that.present )
				place( std::move( *that ) );
			else
				present = false;

			return *this;
		}
开发者ID:CCJY,项目名称:coliru,代码行数:14,代码来源:main.cpp


示例8: Window

ConnectionDialog::ConnectionDialog(const std::string &text,
                                   const State cancelState):
    Window(""),
    gcn::ActionListener(),
    mCancelState(cancelState)
{
    setTitleBarHeight(0);
    setMovable(false);
    setMinWidth(0);

    ProgressIndicator *const progressIndicator = new ProgressIndicator;
    Label *const label = new Label(this, text);
    Button *const cancelButton = new Button(
        // TRANSLATORS: connection dialog button
        this, _("Cancel"), "cancelButton", this);

    place(0, 0, progressIndicator);
    place(0, 1, label);
    place(0, 2, cancelButton).setHAlign(LayoutCell::CENTER);
    reflowLayout();

    center();
}
开发者ID:sangohan,项目名称:tmw-manaplus-client,代码行数:23,代码来源:connectiondialog.cpp


示例9: queen

 int queen(int t)   
 {   
   int i;
     if(t>n && n>0) //当放置的皇后超过n时,可行解个数加1,此时n必须大于0   
       sum++;   
     else  
       for( i=1;i<=n;i++)   
       {   
           x[t] = i; //标明第t个皇后放在第i列   
           if(place(t)) //如果可以放在某一位置,则继续放下一皇后   
             queen(t+1);    
       }   
     return sum;   
 }   
开发者ID:heyuhang,项目名称:linuxC,代码行数:14,代码来源:2.c


示例10: if

		optional& operator=(const optional& that) {
			if (std::addressof(that) == this)
				return *this;
			if (valid() && that.valid())
				**this = *that;
			else if (valid())
				unchecked_destroy();
			else if (that.valid())
				place(*that);
			else
				present = false;

			return *this;
		}
开发者ID:daviddhas,项目名称:CS-gO,代码行数:14,代码来源:optional.hpp


示例11: solve

int solve(int mask, int r, int c) {
  if( r == n ) return 1;

  int nr = (c == n-1 ? r+1 : r), nc = (c == n-1 ? 0 : c+1);

  if( !empty[r][c] ) {
    if( ok(r, c, a[r][c]) ) {
      place(r, c, a[r][c]);
      return solve(mask | (1<<a[r][c]), nr, nc);
    }
    return 0;
  }

  for( int i = square_of_n; i > 0; --i )
    if( !((1<<i) & mask) && ok(r, c, i) ) {
      place(r, c, i);
      int found = solve(mask | (1<<i), nr, nc);
      if( found ) return 1;
      else remove(r, c, i);
    }

  return 0;
}
开发者ID:liuzhengping,项目名称:algo,代码行数:23,代码来源:magic.cpp


示例12: visible

void    Amt::DiagLImpl::applyAttrs(){
	crtc::ItemNode::applyAttrs();
        visible( 1 );
	gtk_widget_show_all(_in_widget);
	if( uart = dynamic_cast<riku::Iuart*>(riku::stdRegister::getRegister().getUart()) ){
	    apply = true;
	    if ((_in_mod_id != "") && !_in_place.length() )
		place((std::string("Место: ")+std::string(uart->get_mPlace(_in_mod_id)) ).c_str() );
	    registerForStep__( );
	}
	else	
	    std::cout<<"\t dynamic_cast crtc::DiagLImpl->Amt::UartImpl ERROR\n";

}
开发者ID:boris-r-v,项目名称:STD,代码行数:14,代码来源:DiagLImpl.cpp


示例13: place

//place a queen in a col of the row
void place(int *pos, int row)
{
	int j;

	for (j = 0; j < N; j++) {
		if (can_place(pos, row, j)) {
			pos[row] = j;
			if (row == N-1)
				output(pos);
			else
				place(pos, row+1);
		}
	}
}
开发者ID:laurie-bai,项目名称:algorithm,代码行数:15,代码来源:eight_queen.c


示例14: sprintf

std::string CodeLocation::str () const
{
  char line [50];
  sprintf (line, "%d", m_line);
  std::string place (m_file);
  place += ":";
  place += line;
  if ( strlen(m_function) ) // skip if compiler does not set function
  {
    place += ":";
    place += m_function;
  }
  return place;
}
开发者ID:Peita,项目名称:coolfluid3,代码行数:14,代码来源:CodeLocation.cpp


示例15: init

void new_player_t::open()
{
	init(gengine);
	place(wmain->x(), wmain->y(), wmain->width(), wmain->height());
	font(B_NORMAL_FONT);
	foreground(wmain->map_rgb(255, 255, 255));
	background(wmain->map_rgb(0, 0, 0));
	memset(name, 0, sizeof(name));
	name[0] = 'A';
	currentIndex = 0;
	editing = 1;
	build_all();
	SDL_EnableUNICODE(1);
}
开发者ID:kuwanger,项目名称:kobodl_gcw0,代码行数:14,代码来源:states.cpp


示例16: place

void Position::applyMove(Square sq)
{
    place(sq, currentPlayer());

    for (int d = 0; d < TOT_DIR; ++d) {
        if (isValidMove(sq, DIR[d]))
            reverse(sq, DIR[d]);
    }

    ++count[currentPlayer()];
    nullMoveCount = 0;

    changePlayer();
}
开发者ID:debug18,项目名称:fkhx,代码行数:14,代码来源:position.cpp


示例17: dosub

void
dosub(uchar *rhsbuf)
{
	uchar *lp, *sp, *rp;
	int c;

	lp = linebuf;
	sp = genbuf;
	rp = rhsbuf;
	while (lp < loc1)
		*sp++ = *lp++;
	while(c = *rp++) {
		if (c == '\\') {
			c = *rp++;
			if (c >= '1' && c < NBRA+'1') {
				sp = place(sp, braslist[c-'1'], braelist[c-'1']);
				continue;
			}
		} else if(c == '&') {
				sp = place(sp, loc1, loc2);
				continue;
		}
		*sp++ = c;
		if (sp >= &genbuf[LBSIZE])
			fprintf(stderr, "sed: Output line too long.\n");
	}
	lp = loc2;
	loc2 = sp - genbuf + linebuf;
	while (*sp++ = *lp++)
		if (sp >= &genbuf[LBSIZE]) {
			fprintf(stderr, "sed: Output line too long.\n");
		}
	lp = linebuf;
	sp = genbuf;
	while (*lp++ = *sp++);
	spend = lp-1;
}
开发者ID:AustenConrad,项目名称:plan-9,代码行数:37,代码来源:sed1.c


示例18: printf

/* 
 * mm_malloc - Allocate a block by incrementing the brk pointer.
 *     Always allocate a block whose size is a multiple of the alignment.
 */
void *mm_malloc(size_t size)
{
    size_t asize;
    /*asize = overrall size with overhead + alignment*/
    size_t extendsize;
    char *bp;
#ifdef DEBUG
    printf("[%d] malloc called with %d\n",++mCnt,size);
#endif

    if(size <= 0)
        return NULL;
    if(size <= WSIZE)
        printf("<WISZE\n");

    if(size <= DSIZE)
        asize = DSIZE + OVERHEAD;
    else
        asize = ALIGN(size + OVERHEAD);

    if((bp = find_fit(asize)) != NULL){
#ifdef DEBUG
        printf("find a slot at %d \n",bp-heap_listp);
#endif
        place(bp,asize);
        return bp;
    }
    //Exam_list(asize);
    extendsize = MAX(asize,C4K);

    if((bp = extend_heap(extendsize/WSIZE)) == NULL)
        return NULL;
    place(bp, asize);

    //Exam_list();
    return bp;
}
开发者ID:cmxcn,项目名称:CSAPP_labs,代码行数:41,代码来源:mm_Impl_nf.c


示例19: mm_init

/*
 * malloc
 */
void *malloc (size_t size) {
    size_t asize;      /* Adjusted block size */
    size_t extendsize; /* Amount to extend heap if no fit */
    char *bp;      

    /* Re-initiate */
    if (first_block == 0){
        mm_init();
    }
    /* Ignore spurious requests */
    if (size == 0)
        return NULL;
    /* Adjust block size to include overhead and alignment*/
    asize = MAX(ALIGN(size + WSIZE), MINSIZE * WSIZE);

    assert(asize >= MINSIZE * WSIZE);

    /* Search the free list for a fit */
    if ((bp = find_fit(asize)) != NULL) {        
        place(bp, asize);                  
#ifdef DEBUG   
        mm_checkheap(1);        
#endif        
        return bp;
    }

    /* No fit found. Get more memory and place the block */
    extendsize = MAX(asize,CHUNKSIZE);                
    if (NULL == (bp = extend_heap(extendsize/WSIZE)))
            return NULL;

    place(bp, asize);                                 
#ifdef DEBUG        
    mm_checkheap(1);    
#endif    
    return bp;
}
开发者ID:csukuangfj,项目名称:15-213-Introduction-to-Computer-Systems,代码行数:40,代码来源:mm.c


示例20: place

/*
 * malloc: adjust the size to the minimum block size or a
 * multiple of alignment. Search the free list for a fit,
 * if not, extend the heap
 */
void *malloc (size_t size) {
    //checkheap(1);  // Let's make sure the heap is ok!
    size_t asize; // adjust size
    size_t extendsize;
    char *bp;

    if (size <= 0){
        return NULL;
    }

    // Adjust the size to at least the minimum blk size and 
    // a multiple of alignment 8
    if (size <= (DSIZE + WSIZE)){
        asize = 2 * DSIZE;
    }
    else{
        asize = DSIZE*((size + DSIZE + (DSIZE - 1)) / DSIZE);
    }

    // search the freelist for a fit 
    if ((bp = findFit(asize)) != NULL){
        place(bp, asize);
        return bp;
    }

    // If no fit, extend the heap
    if(asize>CHUNKSIZE)
        extendsize = asize;
    else
        extendsize = CHUNKSIZE;

    if ((bp = extendHeap(extendsize / WSIZE)) == NULL)
        return NULL;
    place(bp, asize);

    return bp;
}
开发者ID:rainyyang5,项目名称:Computer-System,代码行数:42,代码来源:mengyuy_6_mm.c



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ plainText函数代码示例发布时间:2022-05-30
下一篇:
C++ plabort函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap