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


C++ PREV函数代码示例

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


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

示例1: NCURSES_SP_NAME

NCURSES_SP_NAME(getmouse) (NCURSES_SP_DCLx MEVENT * aevent)
{
    int result = ERR;

    T((T_CALLED("getmouse(%p,%p)"), (void *) SP_PARM, (void *) aevent));

    if ((aevent != 0) && (SP_PARM != 0) && (SP_PARM->_mouse_type != M_NONE)) {
	MEVENT *eventp = SP_PARM->_mouse_eventp;
	/* compute the current-event pointer */
	MEVENT *prev = PREV(eventp);

	if (prev->id != INVALID_EVENT) {
	    /* copy the event we find there */
	    *aevent = *prev;

	    TR(TRACE_IEVENT, ("getmouse: returning event %s from slot %ld",
			      _nc_tracemouse(SP_PARM, prev),
			      (long) IndexEV(SP_PARM, prev)));

	    prev->id = INVALID_EVENT;	/* so the queue slot becomes free */
	    SP_PARM->_mouse_eventp = PREV(prev);
	    result = OK;
	}
    }
    returnCode(result);
}
开发者ID:ysleu,项目名称:RTL8685,代码行数:26,代码来源:lib_mouse.c

示例2: PlayerTrail_PickFirst

edict_t *
PlayerTrail_PickFirst(edict_t *self)
{
	int marker;
	int n;

	if (!trail_active)
	{
		return NULL;
	}

	for (marker = trail_head, n = TRAIL_LENGTH; n; n--)
	{
		if (trail[marker]->timestamp <= self->monsterinfo.trail_time)
		{
			marker = NEXT(marker);
		}
		else
		{
			break;
		}
	}

	if (visible(self, trail[marker]))
	{
		return trail[marker];
	}

	if (visible(self, trail[PREV(marker)]))
	{
		return trail[PREV(marker)];
	}

	return trail[marker];
}
开发者ID:ryonagana,项目名称:ctf,代码行数:35,代码来源:trail.c

示例3: swap

short int swap(Triangle * a, Triangle * b){
	int ua, ub;
	for(ua=0; ua<3 && IN_TRIA(b, a->points[ua]); ++ua);
	for(ub=0; ub<3 && IN_TRIA(a, b->points[ub]); ++ub);
	if(ua==3 || ub==3) return -1;
	a->points[NEXT(ua)] = b->points[ub];
	b->points[b->points[NEXT(ub)] == a->points[PREV(ua)] ? NEXT(ub) : PREV(ub)] = a->points[ua];
	return 1;
}
开发者ID:apanouso,项目名称:contiki-topology-control,代码行数:9,代码来源:definitions.c

示例4: findstats

static void
findstats(Pos p, Ori o)
{
	/* Recalculate cross assert and score total at 'p'
	 */
	Pos	left, right;
	Word lword, rword;
	Node n;
	Edge e;
	int	s;

	lword.n = rword.n = 0;
	if(EDGE(p))
		return;

	/* find word to the left */
	s = 0;
	for(left=PREV(p,o); HASLETTER(left); left = PREV(left,o))
		;
	left = NEXT(left,o);
	while (HASLETTER(left)) {
		lword.c[lword.n++] = LETTER(left);
		s += SCORE(left);
		left = NEXT(left,o);
	}
	/* find word to the right */
	for(right=NEXT(p,o); HASLETTER(right); right = NEXT(right,o)) {
		rword.c[rword.n++] = LETTER(right);
		s += SCORE(right);
	}
	if(DBG) {
		wordprint(&lword);
		print("X");
		wordprint(&rword);
		print(" [%d] ", s);
	}

	SIDE(p,o) = s;
	ISANCHOR(p) = true;

	/* calculate cross asserts */
	CROSS(p,o) = 0;
	n = traverse(root, &lword, 0);
	assert(n>=0);
	if(n>0)
		do {
			e = dict[n++];
			if ( (rword.n && isword(NODE(e), &rword)) || 
				 (!rword.n && TERM(e)) ) {
				CROSS(p,o) |= 1 << LET(e);
				DPRINT("%c, ", LET(e)+'a');
			}
		} while (!(LAST(e)));
	DPRINT("\n");
}
开发者ID:Who8MyLunch,项目名称:Eat_Words,代码行数:55,代码来源:play.c

示例5: xdr_amq_mount_info_qelem

bool_t
xdr_amq_mount_info_qelem(XDR *xdrs, qelem *qhead)
{
  mntfs *mf;
  u_int len = 0;

  /*
   * Compute length of list
   */
  for (mf = AM_LAST(mntfs, qhead); mf != HEAD(mntfs, qhead); mf = PREV(mntfs, mf)) {
    if (!(mf->mf_fsflags & FS_AMQINFO))
      continue;
    len++;
  }
  xdr_u_int(xdrs, &len);

  /*
   * Send individual data items
   */
  for (mf = AM_LAST(mntfs, qhead); mf != HEAD(mntfs, qhead); mf = PREV(mntfs, mf)) {
    int up;
    if (!(mf->mf_fsflags & FS_AMQINFO))
      continue;

    if (!xdr_amq_string(xdrs, &mf->mf_ops->fs_type)) {
      return (FALSE);
    }
    if (!xdr_amq_string(xdrs, &mf->mf_mount)) {
      return (FALSE);
    }
    if (!xdr_amq_string(xdrs, &mf->mf_info)) {
      return (FALSE);
    }
    if (!xdr_amq_string(xdrs, &mf->mf_server->fs_host)) {
      return (FALSE);
    }
    if (!xdr_int(xdrs, &mf->mf_error)) {
      return (FALSE);
    }
    if (!xdr_int(xdrs, &mf->mf_refc)) {
      return (FALSE);
    }
    if (FSRV_ERROR(mf->mf_server) || FSRV_ISDOWN(mf->mf_server))
      up = 0;
    else if (FSRV_ISUP(mf->mf_server))
      up = 1;
    else
      up = -1;
    if (!xdr_int(xdrs, &up)) {
      return (FALSE);
    }
  }
  return (TRUE);
}
开发者ID:CTSRD-CHERI,项目名称:cheribsd,代码行数:54,代码来源:amq_subr.c

示例6: NextLink

/*** Go through the next word ***/
void NextLink( AGNode src, char dir )
{
	if( dir == 1)
		if( src->ActiveLink ) src->ActiveLink = NEXT(src->ActiveLink);
		else src->ActiveLine++, src->ActiveLink = WordsPara(
		     src->StartLine = NEXT(src->StartLine) );
	else
		if( src->ActiveLink ) src->ActiveLink = PREV(src->ActiveLink);
		else src->ActiveLine--, src->ActiveLink =
		     EndOfLine( src->StartLine = PREV(src->StartLine) );
}
开发者ID:shintakezou,项目名称:agreader,代码行数:12,代码来源:Navigate.c

示例7: main

int main(int argc, char *argv[])
{
#define COUNT (10)
  struct mydata data[COUNT];
  int i;
  struct mydata *pcur, *plast = data;
  INIT_LIST(plast);
  plast->data1 = -222;
  plast->data2 = -999000.0;
    
  for(i=1; i<COUNT; i++) {
    pcur = data + i;
    INIT_LIST(pcur);
    pcur->data1 = i;
    pcur->data2 = i + 999300.0;
    ADD_AFTER(plast, pcur);
    
    plast = NEXT(plast);
  }
  
  struct mydata *ptr = data;
  while(ptr) {
    printf("data1=%d, data2=%f\n", ptr->data1, ptr->data2);
    ptr = NEXT(ptr);
  }
  
  ptr = data + COUNT - 1;
  while(ptr) {
    printf("data1=%d, data2=%f\n", ptr->data1, ptr->data2);
    ptr = PREV(ptr);
  }
  return 0;
}
开发者ID:pombredanne,项目名称:pcc,代码行数:33,代码来源:test_list.c

示例8: insert_vert

// Insert a new vertex
static void insert_vert(TriMesh *mesh, int scheme, int f, int e)
{
	int v1 = mesh->faces[f][NEXT(e)], v2 = mesh->faces[f][PREV(e)];
	if (scheme == SUBDIV_PLANAR) {
		point p = 0.5f * (mesh->vertices[v1] +
				  mesh->vertices[v2]);
		mesh->vertices.push_back(p);
		return;
	}

	int ae = mesh->across_edge[f][e];
	if (ae == -1) {
		// Boundary
		point p = 0.5f * (mesh->vertices[v1] +
				  mesh->vertices[v2]);
		if (scheme == SUBDIV_BUTTERFLY ||
		    scheme == SUBDIV_BUTTERFLY_MODIFIED) {
			p *= 1.5f;
			p -= 0.25f * (avg_bdy(mesh, v1) + avg_bdy(mesh, v2));
		}
		mesh->vertices.push_back(p);
		return;
	}

	int v0 = mesh->faces[f][e];
	const TriMesh::Face &aef = mesh->faces[ae];
	int v3 = aef[NEXT(aef.indexof(v1))];
	point p;
	if (scheme == SUBDIV_LOOP || scheme == SUBDIV_LOOP_ORIG) {
		p = loop(mesh, f, ae, v0, v1, v2, v3);
	} else if (scheme == SUBDIV_LOOP_NEW) {
		bool e1 = (mesh->adjacentfaces[v1].size() != 6);
		bool e2 = (mesh->adjacentfaces[v2].size() != 6);
		if (e1 && e2)
			p = 0.5f * (new_loop_edge(mesh, f, ae, v0, v1, v2, v3) +
				    new_loop_edge(mesh, ae, f, v3, v2, v1, v0));
		else if (e1)
			p = new_loop_edge(mesh, f, ae, v0, v1, v2, v3);
		else if (e2)
			p = new_loop_edge(mesh, ae, f, v3, v2, v1, v0);
		else
			p = loop(mesh, f, ae, v0, v1, v2, v3);
	} else if (scheme == SUBDIV_BUTTERFLY) {
		p = butterfly(mesh, f, ae, v0, v1, v2, v3);
	} else if (scheme == SUBDIV_BUTTERFLY_MODIFIED) {
		bool e1 = (mesh->adjacentfaces[v1].size() != 6);
		bool e2 = (mesh->adjacentfaces[v2].size() != 6);
		if (e1 && e2)
			p = 0.5f * (zorin_edge(mesh, f, ae, v0, v1, v2, v3) +
				    zorin_edge(mesh, ae, f, v3, v2, v1, v0));
		else if (e1)
			p = zorin_edge(mesh, f, ae, v0, v1, v2, v3);
		else if (e2)
			p = zorin_edge(mesh, ae, f, v3, v2, v1, v0);
		else
			p = butterfly(mesh, f, ae, v0, v1, v2, v3);
	}

	mesh->vertices.push_back(p);
}
开发者ID:THTBSE,项目名称:Stability,代码行数:61,代码来源:subdiv.cpp

示例9: ft_think

void			ft_think(t_env *e, int l, int i)
{
    int		c;
    int		rt;

    c = 0;
    rt = THINK_T * TT;
    e->i_state[i] = 0;
    e->state[i] = ft_strdup(THINK);
    while (c < rt)
    {
        if (ft_is_dead(e) != 0)
            e->roll = 3;
        if ((c % TT) == 0)
            e->hp[i] -= 1;
        if (e->i_state[NEXT(i)] == 1 || e->i_state[PREV(i)] == 1)
        {
            UNLOCK(&e->lock[l]);
            return (ft_rest(e, i, c));
        }
        usleep(TS);
        if (e->roll == 3)
            break ;
        c++;
    }
    UNLOCK(&e->lock[l]);
}
开发者ID:Sequoya42,项目名称:turbulent-octo-broccoli,代码行数:27,代码来源:philosopher.c

示例10: legalizeEdge

short int legalizeEdge(Point * p, Triangle * T){
	short int ut, ua;
	Triangle * A;
	Point * center;

	for(ut=0; ut<3 && T->points[ut] != p; ++ut);
	if(ut==3) return -1;

	ADJACENT(T, T->points[NEXT(ut)], T->points[PREV(ut)], A);

	if(!A) return 1;

	for(ua=0; ua<3 && IN_TRIA(T, A->points[ua]); ua++);

	center = calcCenter(T);
	if(!center) return -2;

	if(DISQR(A->points[ua], center) >= DISQR(center, P0)){
		free(center);
		return 1;
	}
	free(center);

	if((ua=swap(T, A))<0) return -3;

	if((ua=legalizeEdge(p, T))<0) return -ua;
	if((ua=legalizeEdge(p, A))<0) return -ua;

	return 1;
}
开发者ID:apanouso,项目名称:contiki-topology-control,代码行数:30,代码来源:definitions.c

示例11: movelines

int movelines ( char *linespec , double_list *p_head, double_list *p_current ) {

  double_list startnode, endnode, tmpnode ;
  int startnumber, endnumber, rc, currentnumber, tmp;

  rc = parse_linespec( linespec, *p_head, *p_current, &startnode, &endnode ) ;

  if( rc )
    return rc ;

  startnumber = double_node_number( startnode ) ;
  endnumber = double_node_number( endnode ) ;
  currentnumber = double_node_number( *p_current ) ;

  if( startnumber > endnumber ) {

    tmp = startnumber ;
    startnumber = endnumber ;
    endnumber = tmp ;
    tmpnode = startnode ;
    startnode = endnode ;
    endnode = tmpnode ;
  }

  if(( currentnumber >= startnumber ) && ( currentnumber <= endnumber ))
    return E_LINES;

  cut_list( p_head, &startnode, &endnode ) ;
  paste_list( &PREV( *p_current ), &startnode ) ;
 
  return 0;
}
开发者ID:Gruul,项目名称:Simple_Line_Editor,代码行数:32,代码来源:user.c

示例12: txstart

static void
txstart(Ether *edev)
{
	int tdh, tdt;
	Ctlr *ctlr = edev->ctlr;
	Block *bp;
	Tdesc *tdesc;

	/*
	 * Try to fill the ring back up, moving buffers from the transmit q.
	 */
	tdh = PREV(ctlr->tdh, Ntdesc);
	for(tdt = ctlr->tdt; tdt != tdh; tdt = NEXT(tdt, Ntdesc)){
		/* pull off the head of the transmission queue */
		if((bp = ctlr->bqhead) == nil)	/* was qget(edev->oq) */
			break;
		ctlr->bqhead = bp->next;
		if (ctlr->bqtail == bp)
			ctlr->bqtail = nil;

		/* set up a descriptor for it */
		tdesc = &ctlr->tdba[tdt];
		tdesc->addr[0] = PCIWADDR(bp->rp);
		tdesc->addr[1] = 0;
		tdesc->control = /* Ide | */ Rs | Ifcs | Teop | BLEN(bp);

		ctlr->tb[tdt] = bp;
	}
	ctlr->tdt = tdt;
	csr32w(ctlr, Tdt, tdt);
	i82563im(ctlr, Txdw);
}
开发者ID:AustenConrad,项目名称:plan-9,代码行数:32,代码来源:ether82563.c

示例13: mm_malloc

/*
 * mm_realloc - Implemented simply in terms of mm_malloc and mm_free
 */
void *mm_realloc(void *ptr, size_t size)
{   
    size_t asize;  //adjusted block size
    if (size <= DSIZE)
        asize = 2*DSIZE;
    else 
        asize = DSIZE * ((size + (DSIZE)+(DSIZE-1))/DSIZE);
    
    size_t oldSize=GET_SIZE(HDRP(ptr));
    size_t nextSize=GET_SIZE(HDRP(NEXT_BLKP(ptr)));
    //if two blocks can fit, then we just return the original ptr and adjust the size
    if(!GET_ALLOC(HDRP(NEXT_BLKP(ptr)))){
        if(asize < (oldSize+nextSize-2*DSIZE)){
            void *bp=ptr;
            void* prevfree=PREV(NEXT_BLKP(ptr));
            void* nextfree=NEXT(NEXT_BLKP(ptr));

            PUT(HDRP(bp),PACK(asize,1));
            PUT(FTRP(bp),PACK(asize,1));
            bp=(char*)bp+asize;
            PUT(HDRP(bp),PACK(oldSize+nextSize-asize,0));
            PUT(FTRP(bp),PACK(oldSize+nextSize-asize,0));
            PUT(bp,prevfree);

            if(prevfree)
                PUT(SUC(prevfree),bp);
            if(nextfree)
                PUT(nextfree,bp);
            else endfree=bp;
            return ptr;
        }
    }

    //else...
    void *oldptr = ptr;
    size_t copySize;
    void *newptr;

    if(ptr == NULL)
       return mm_malloc(size);
 
    if (asize==0) {
        mm_free(oldptr);
        return NULL;
    }
   
    else{
        newptr = mm_malloc(size);
        if (newptr == NULL)
           return NULL;
        copySize = GET_SIZE(HDRP(oldptr));
        if (asize < copySize)
           copySize = asize;
        memcpy(newptr, oldptr, copySize-WSIZE);
        mm_free(oldptr);
        return newptr;
    }
}
开发者ID:RayneZhang,项目名称:csapp-lab,代码行数:61,代码来源:mm.c

示例14: cmd_goto_left

void cmd_goto_left(CmdContext *c, CmdParams *p)
{
	gint i;
	gint start_pos = p->line_start_pos;
	gint pos = p->pos;
	for (i = 0; i < p->num && pos > start_pos; i++)
		pos = PREV(p->sci, pos);
	SET_POS(p->sci, pos, TRUE);
}
开发者ID:StephenWassell,项目名称:geany-plugins,代码行数:9,代码来源:motion.c

示例15: Ins_count

// get the element count in the doubly linked list
// will calculate both two directions in the list
int Ins_count(const Ins *n)
{
  if( !n ) return 0;
  int i = 0;
  
  const Ins *n2 = PREV(n);
 
  while( n ) {
    n = NEXT(n);
    i++; 
  }
  while( n2 ) {
    n2 = PREV(n2);
    i++;
    
  }
  return i;
}
开发者ID:pombredanne,项目名称:pcc,代码行数:20,代码来源:Ins_node.c


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