本文整理汇总了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;
}
示例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);
}
示例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;
}
示例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 );
}
}
示例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++;
}
}
示例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);
}
}
示例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);
}
}
示例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;
}
示例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));
}
}
示例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;
}
}
}
示例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;
}
示例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);
}
示例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;
}
}
}
示例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;
}
示例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);
}
}