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


C++ PARENT函数代码示例

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


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

示例1: tmevtb_delete

void
tmevtb_delete(TMEVTB *p_tmevtb)
{
	uint_t	index = p_tmevtb->index;
	uint_t	parent;
	EVTTIM	event_time = TMEVT_NODE(last_index).time;

	/*
	 *  last_index--
	 *  if last_index == 0
	 *  do nothing.
	 */
	if (--last_index == 0) {
		return;
	}

	/*
	 *
	 *  insert the last time event into the position of deleted time
	 *  event. In fact, the insert does not happened. The position of 
	 *  deleted time will be a empty node in time event heap. Then this
	 *  empty node will be moved to a right position which is the right
	 *  position of the last time event. 
	 * 
	 *  If the event time of the last time event is earlier than deleted
	 *  time event's parent, then search up, or search down.
	 *
	 */
	if (index > 1 && EVTTIM_LT(event_time,
								TMEVT_NODE(parent = PARENT(index)).time)) {
		/*
		 *  if deleted time event's parent is not earlier than last time event
		 *  in heap, change parent's position and update info.
		 * 
		 */
		TMEVT_NODE(index) = TMEVT_NODE(parent);
		TMEVT_NODE(index).p_tmevtb->index = index;

		/*
		 *  then search up to find the right position for the last time event in heap
		 *  from parent's position
		 */
		index = tmevt_up(parent, event_time);
	}
	else {
		/*
		 *  search down to find right position for last time event in heap.
		 */
		index = tmevt_down(index, event_time);
	}

	/*
	 * update the last time event's info
	 */ 
	TMEVT_NODE(index) = TMEVT_NODE(last_index + 1);
	TMEVT_NODE(index).p_tmevtb->index = index;
}
开发者ID:bzchangguopeng,项目名称:toppers-asp,代码行数:57,代码来源:time_event.c

示例2: _sio_timer_adjust_heap

static void _sio_timer_adjust_heap(struct sio_timer_manager *st_mgr, struct sio_timer *timer)
{
    uint64_t parent = PARENT(timer);
    
    if (parent && timer->expire < st_mgr->heap_nodes[parent]->expire) 
        _sio_timer_upheap(st_mgr, timer);
    else
        _sio_timer_downheap(st_mgr, timer);
}
开发者ID:owenliang,项目名称:simple_kit,代码行数:9,代码来源:sio_timer.c

示例3: bookSetup

HWND bookSetup( ULONG idInitialPage )
{
    HWND hwndFrame;

    if( hwndBook )
    {
        hwndFrame = PARENT( hwndBook );

        // For some reason it is necessary to restore the notebook before
        // setting the frame as the active window if the frame is being
        // restored from a minimized state.

        WinSetWindowPos( hwndBook, NULLHANDLE, 0, 0, 0, 0,
                         SWP_SHOW | SWP_RESTORE );
        WinSetWindowPos( hwndFrame, NULLHANDLE, 0, 0, 0, 0,
                         SWP_SHOW | SWP_RESTORE | SWP_ACTIVATE );
    }
    else
    {
        FRAMECDATA fcdata;

        memset( &fcdata, 0, sizeof fcdata );
        fcdata.cb            = sizeof( FRAMECDATA );
        fcdata.flCreateFlags = FRAME_FLAGS;
        fcdata.idResources   = ID_NBFRAME;

        hwndFrame = WinCreateWindow( HWND_DESKTOP, WC_FRAME, NULL, WS_ANIMATE,
                                     0, 0, 0, 0, NULLHANDLE, HWND_TOP,
                                     ID_NBFRAME, &fcdata, NULL );
        if( hwndFrame )
        {
            pfnwpFrame = WinSubclassWindow( hwndFrame, wpNBFrame );
            if( pfnwpFrame )
                if( CreateNotebookWindow( hwndFrame ) )
                    WinSetWindowText( hwndFrame, BOOK_TITLE );
                else
                {
                    WinDestroyWindow( hwndFrame );
                    hwndFrame = NULLHANDLE;
                }
            else
            {
                WinDestroyWindow( hwndFrame );
                Msg( "bookSetup WinSubclassWindow RC(%X)", HWNDERR(hwndFrame) );
                hwndFrame = NULLHANDLE;
            }
        }
        else
            Msg( "bookSetup WinCreateWindow of frame window RC(%X)", HABERR(0));
    }

    if( hwndBook )
        TurnToPage( idInitialPage );

    return hwndFrame;
}
开发者ID:OS2World,项目名称:DEV-SAMPLES-PM-DRGDROP,代码行数:56,代码来源:notebook.c

示例4: heap_build

/*****************************************************************************
 * heap_build
 *
 * Build a heap from an unordered array.
 *****************************************************************************/
void heap_build( heap_t *heap )
{
    GLint	i;

    heap->size = heap->length;

    for ( i = PARENT( heap->length ) ; i >= 0 ; i-- ) {
	heapify( heap, i );
    }
}
开发者ID:OS2World,项目名称:LIB-VIDEO-MGL,代码行数:15,代码来源:tess_heap.c

示例5: priority

void priority(BinHeap *bh, int data, int newPriority){
    long i = 0, k;
    while (i < bh->size){
        if (bh->A[i].data == data){
            printf("sosi%d \n", newPriority);
            if (newPriority < bh->A[i].priority){
                bh->A[i].priority = newPriority;
                k = i;
                while(k && newPriority < bh->A[PARENT(k)].priority) {
                    bh->A[k] = bh->A[PARENT(k)];
                    k = PARENT(k);
                }
                bh->A[k].priority = newPriority;
                bh->A[k].data = data;
            }
        }
        i++;
    }
}
开发者ID:MykolaMedynskyi,项目名称:MyRepository,代码行数:19,代码来源:main.c

示例6: insert_heap

void insert_heap(puzzle b)
{
   puzzle tmp;
   int    index;

   if (heap_size == MAX_HEAP_SIZE) {
      printf ("Heap overflow\n");
      exit(-1);
   }
   heap[heap_size] = b;
   index = heap_size;
   heap_size++;
   while ((index > 0) && superior(index, PARENT(index))) {
      tmp = heap[index];
      heap[index] = heap[PARENT(index)];
      heap[PARENT(index)] = tmp;
      index = PARENT(index);
   }
}
开发者ID:Kartonschachtel,项目名称:public,代码行数:19,代码来源:puzzle15seq.c

示例7: pqueue_enqueue

void
pqueue_enqueue(pqueue_t *queue, const void *data) {
	size_t i;
	void *tmp = NULL;
	if (queue == NULL || queue->size >= queue->capacity)
		return;
	/* adds element last */
	queue->data[queue->size] = (void*)data;
	i = queue->size;
	queue->size++;

	/* the new element is swapped with its parent as long as its precedence is higher */
	while(i > 0 && queue->cmp(queue->data[i], queue->data[PARENT(i)]) > 0) {
		tmp = queue->data[i];
		queue->data[i] = queue->data[PARENT(i)];
		queue->data[PARENT(i)] = tmp;
		i = PARENT(i);
	}
}
开发者ID:patseb,项目名称:scgl,代码行数:19,代码来源:pqueue.c

示例8: PARENT

static void
dvb_flush			(vbi_capture *		cap)
{
	vbi_capture_dvb *dvb = PARENT (cap, vbi_capture_dvb, capture);

	vbi_dvb_demux_reset (dvb->demux);

	dvb->bp = dvb->pes_buffer;
	dvb->b_left = 0;
}
开发者ID:nagyistoce,项目名称:canalplus-r7oss,代码行数:10,代码来源:io-dvb.c

示例9: INFO

void DominatorTree::debugPrint()
{
   for (int i = 0; i < count; ++i) {
      INFO("SEMI(%i) = %i\n", i, SEMI(i));
      INFO("ANCESTOR(%i) = %i\n", i, ANCESTOR(i));
      INFO("PARENT(%i) = %i\n", i, PARENT(i));
      INFO("LABEL(%i) = %i\n", i, LABEL(i));
      INFO("DOM(%i) = %i\n", i, DOM(i));
   }
}
开发者ID:Distrotech,项目名称:Mesa,代码行数:10,代码来源:nv50_ir_ssa.cpp

示例10: up

void up(struct minheap * mh,int index) 
{
	int parent = PARENT(index);
	while(parent >= 1)
	{
		assert(mh->elts[index]);
		assert(mh->elts[parent]);
		if (mh->less(mh->ud,mh->elts[index],mh->elts[parent]))
		{
			swap(mh,index,parent);
			index = parent;
			parent = PARENT(index);
		}
		else 
		{
			break;
		}
	}
}
开发者ID:xvly,项目名称:fish,代码行数:19,代码来源:MiniHeap.cpp

示例11: BSTreeDepth

/* BSTreeDepth
 *  returns number of layers in b-tree
 *
 *  if "exact" is 1, then the maximum
 *  depth is returned. otherwise, the depth of
 *  an arbitrary leaf node is returned
 */
LIB_EXPORT uint32_t CC BSTreeDepth ( const BSTree *bt, bool exact )
{
    BSTNode *p;
    uint32_t depth;

    if ( bt == NULL || bt -> root == NULL )
        return 0;

    depth = 1;

    if ( exact )
    {
        for ( p = FirstNode ( bt ); p != NULL; p = BSTNodeNext ( p ) )
        {
            BSTNode *q;
            unsigned int ndepth;

            if ( p -> child [ 0 ] != NULL || p -> child [ 1 ] != NULL )
                continue;

            for ( ndepth = 1, q = PARENT ( p ); q != NULL; q = PARENT ( q ) )
                ++ ndepth;

            if ( ndepth > depth )
                depth = ndepth;
        }
    }
    else
    {
        for ( p = bt -> root;; ++ depth )
        {
            if ( p -> child [ 0 ] != NULL )
                p = p -> child [ 0 ];
            else if ( p -> child [ 1 ] != NULL )
                p = p -> child [ 1 ];
            else
                break;
        }
    }

    return depth;
}
开发者ID:thelegend6420,项目名称:ncbi-vdb,代码行数:49,代码来源:container.c

示例12: bubble_up

static void
bubble_up(pq q, unsigned int k)
{
    int p;

    if (k == 0) return;
    p = PARENT(k);
    if (cmp(q, p, k) <= 0) return;
    swap(q, k, p);
    bubble_up(q, p);
}
开发者ID:rainly,项目名称:beanstalkd,代码行数:11,代码来源:pq.c

示例13: SEMI

void DominatorTree::buildDFS(Graph::Node *node)
{
   SEMI(node->tag) = node->tag;

   for (Graph::EdgeIterator ei = node->outgoing(); !ei.end(); ei.next()) {
      if (SEMI(ei.getNode()->tag) < 0) {
         buildDFS(ei.getNode());
         PARENT(ei.getNode()->tag) = node->tag;
      }
   }
}
开发者ID:Distrotech,项目名称:Mesa,代码行数:11,代码来源:nv50_ir_ssa.cpp

示例14: BSTreeContains

static
bool CC BSTreeContains ( const BSTNode *root, const BSTNode *n )
{
    while ( n != NULL )
    {
        if ( n == root )
            return true;
        n = PARENT ( n );
    }
    return false;
}
开发者ID:thelegend6420,项目名称:ncbi-vdb,代码行数:11,代码来源:container.c

示例15: TimerAddNode

// Adds a timer to the heap, using timer_node data. Passed
// timer_node is first unused element in timer_heap array.
__forceinline void TimerAddNode(timer_node *t)
{
   if (numActiveTimers == 0 || timer_heap[0]->time > t->time)
   {
      // We're making a new first-timer, so the time main loop should wait might
      // have changed, so have it break out of loop and recalibrate
      MessagePost(main_thread_id, WM_BLAK_MAIN_RECALIBRATE, 0, 0);
   }

   // Start node off at end of heap.
   int i = numActiveTimers++;
   timer_heap[i]->heap_index = i;

   // Push node up if necessary.
   while (i > 0 && timer_heap[i]->time < timer_heap[PARENT(i)]->time)
   {
      TimerSwapIndex(i, PARENT(i));
      i = PARENT(i);
   }
}
开发者ID:MorbusM59,项目名称:Meridian59,代码行数:22,代码来源:timer.c


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