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

C++ RIGHT函数代码示例

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

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



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

示例1: Heapify

void Heapify(PQ h, int i) { 
  int l, r, largest; 
  l = LEFT(i); 
  r = RIGHT(i); 
  if (l < h->heapsize && greater(h->array[l], h->array[i])) 
    largest = l; 
  else  
    largest = i; 
  if (r<h->heapsize && greater(h->array[r], h->array[largest])) 
    largest = r; 
  if (largest != i) { 
    swap(h, i, largest); 
    Heapify(h, largest); 
  } 
  return; 
} 
开发者ID:ewaves,项目名称:laboratori,代码行数:16,代码来源:PQ.c


示例2: max_heapify

void max_heapify(int *array, int heap_size, int i)
{
	int largest = i;
	int l = LEFT(i);
	int r = RIGHT(i);
	if( l < heap_size && array[l] > array[largest])
		largest = l;
	if( r < heap_size && array[r] > array[largest])
		largest = r;
	if(largest != i) {
		int temp = array[i];
		array[i] = array[largest];
		array[largest] = temp;
		max_heapify(array, heap_size, largest);
	}
}
开发者ID:Banchon,项目名称:algorithm,代码行数:16,代码来源:heap_sort.c


示例3: _ecore_sheap_heapify

/*
 * Regain the heap properties starting at position i
 * @param  heap The heap to regain heap properties
 * @param  i    The position to start heapifying
 */
static void
_ecore_sheap_heapify(Ecore_Sheap *heap, int i)
{
   int extreme;
   int left = LEFT(i);
   int right = RIGHT(i);

   if (heap->order == ECORE_SORT_MIN)
     {
	if (left <= heap->size && heap->compare(heap->data[left - 1],
						heap->data[i - 1]) < 0)
	  extreme = left;
	else
	  extreme = i;

	if (right <= heap->size && heap->compare(heap->data[right - 1],
						 heap->data[extreme - 1]) < 0)
	  extreme = right;
     }
   else
     {
	if (left <= heap->size && heap->compare(heap->data[left - 1],
						heap->data[i - 1]) > 0)
	  extreme = left;
	else
	  extreme = i;

	if (right <= heap->size && heap->compare(heap->data[right - 1],
						 heap->data[extreme - 1]) > 0)
	  extreme = right;
     }

   /*
    * If the data needs to be swapped down the heap, recurse on
    * heapifying it's new placement.
    */
   if (extreme != i)
     {
	void *temp;

	temp = heap->data[extreme - 1];
	heap->data[extreme - 1] = heap->data[i - 1];
	heap->data[i - 1] = temp;

	_ecore_sheap_heapify(heap, extreme);
     }
}
开发者ID:OpenInkpot-archive,项目名称:iplinux-eina,代码行数:52,代码来源:ecore_sheap.c


示例4: ternary_sift_down

void ternary_sift_down(void *base,
                       size_t start,
                       size_t size,
                       size_t max_index,
                       compare_fun3 compare,
                       void *arg) {
  size_t root = start;
  while (TRUE) {
    size_t left_child = LEFT(root);
    if (left_child > max_index) {
      break;
    }
    void *root_ptr = POINTER(base, root, size);
    size_t swap = root;
    void *swap_ptr = root_ptr;
    void *left_child_ptr = POINTER(base, left_child, size);
    if (compare(swap_ptr, left_child_ptr, arg) < 0) {
      swap = left_child;
      swap_ptr = left_child_ptr;
    }
    size_t middle_child = MIDDLE(root);
    size_t right_child = RIGHT(root);
    if (middle_child <= max_index) {
      void *middle_child_ptr = POINTER(base, middle_child, size);
      if (compare(swap_ptr, middle_child_ptr, arg) < 0) {
        swap = middle_child;
        swap_ptr = middle_child_ptr;
      }
      if (right_child <= max_index) {
        void *right_child_ptr = POINTER(base, right_child, size);
        if (compare(swap_ptr, right_child_ptr, arg) < 0) {
          swap = right_child;
          swap_ptr = right_child_ptr;
        }
      }
    }

    if (swap != root) {
      swap_elements(root_ptr, swap_ptr, size);
      root = swap;
      root_ptr = swap_ptr;
    } else {
      return;
    }
  }
}
开发者ID:alexgustafson,项目名称:vagrant_sysprogramming,代码行数:46,代码来源:ternary-hsort.c


示例5: bstree_delete_index_balanced

int bstree_delete_index_balanced( bstree_t *tree_in, long idx_in )
{
	int ret;
	long temp;
	if( bstree_delete_index( tree_in, idx_in, &temp ) < 0 )
		return -1;
	if( COLOR(temp) == BLACK )
	{
		if( LEFT(temp) != -1 )
			temp = LEFT(temp);
		else
			temp = RIGHT(temp);
		if( bstree_balance_delete( tree_in, temp ) < 0 )
			return -1;
	}
	return 0;
}
开发者ID:mathemaphysics,项目名称:util,代码行数:17,代码来源:trees.c


示例6: minheapify

void minheapify(Heap heap, int i)
{
    int l = LEFT(i);
    int r = RIGHT(i);
    int minimal = i;
    if(l < heap.length && heap.a[l]->key < heap.a[i]->key) 
        minimal = l;
    if(r < heap.length && heap.a[r]->key < heap.a[minimal]->key)
        minimal = r;
    if(minimal != i)
    {
        HeapNode *temp = heap.a[i];
        heap.a[i] = heap.a[minimal];
        heap.a[minimal] = temp;
        minheapify(heap, minimal);
    }
}
开发者ID:LiChenda,项目名称:hf,代码行数:17,代码来源:minheap.c


示例7: detect

void BeatDetector::detect(uint8_t* stream) {
    /* calculate local average energy */
    double average_energy = 0;

    for(uint32_t i = 0; i<samples; i++)
    {
        double L = (double)LEFT((int16_t *) stream, i);
        double R = (double)RIGHT((int16_t *) stream, i);
        average_energy += L*L + R*R;
    }

    /* if local average is greater than S x global average then it's a beat! */
    beat = ((average_energy * history_len) > (sensitivity * H->total)) * average_energy;

    /* update history buffer */
    H->record(average_energy);
}
开发者ID:stevespijderman,项目名称:bassinvaders,代码行数:17,代码来源:BeatDetector.cpp


示例8: G_ReactionFireTargetsUpdateAll

/**
 * @brief Check whether 'target' has just triggered any new reaction fire
 * @param[in] target The entity triggering fire
 */
static void G_ReactionFireTargetsUpdateAll (const edict_t *target)
{
	edict_t *shooter = NULL;

	/* check all possible shooters */
	while ((shooter = G_EdictsGetNextLivingActor(shooter))) {
		/* check whether reaction fire is possible (friend/foe, LoS */
		if (G_ReactionFireIsPossible(shooter, target)) {
			const int TUs = G_ReactionFireGetTUsForItem(shooter, target, RIGHT(shooter));
			if (TUs < 0)
				continue;	/* no suitable weapon */
			G_ReactionFireTargetsAdd(shooter, target, TUs);
		} else {
			G_ReactionFireTargetsRemove(shooter, target);
		}
	}
}
开发者ID:MyWifeRules,项目名称:ufoai-1,代码行数:21,代码来源:g_reaction.cpp


示例9: max_heapify

void max_heapify(int A[], int i, int size)
{
    int l = LEFT(i);
    int r = RIGHT(i);
    int largest = i;
    if (l < size && A[l] > A[i])
        largest = l;

    if (r < size && A[r] > A[largest])
        largest = r;

    if (largest != i)
    {
        my_swap(&A[i], &A[largest]);
        max_heapify(A, largest, size);
    }
}
开发者ID:yurenjimi,项目名称:ITA,代码行数:17,代码来源:heap_sort.c


示例10: os_key_rank

int os_key_rank(const Node *T, int key)
{
	Node *p = const_cast<Node*>(T);
	int r = 0;
	while(NIL != p) {
		if (key == KEY(p)) {
			return r + SIZE(LEFT(p)) + 1;
		} else if (key < KEY(p)){
			p = LEFT(p);
		} else {
			r += SIZE(LEFT(p)) + 1;
			p = RIGHT(p);
		}
	}

	return 0;
}
开发者ID:jarfield,项目名称:SolutionToCLR2nd,代码行数:17,代码来源:tree.cpp


示例11: min_heapify

void min_heapify(MinQueue *q, int i)
{
    int l, r, smallest;
    l = LEFT(i);
    r = RIGHT(i);
    if( l <= q->size && (d[q->heap[l]] < d[q->heap[i]]))
        smallest = l;
    else
        smallest = i;
    if( r <= q->size && (d[q->heap[r]] < d[q->heap[smallest]]))
        smallest = r;
    if(smallest != i)
    {
        exchange(&(q->heap[i]), &(q->heap[smallest]));
        min_heapify(q, smallest);
    }
}
开发者ID:doudouOUC,项目名称:algorithms,代码行数:17,代码来源:dijkstra.c


示例12: CL_ActorCvars

/**
 * @brief Updates the character cvars for the given character.
 *
 * The models and stats that are displayed in the menu are stored in cvars.
 * These cvars are updated here when you select another character.
 *
 * @param[in] chr Pointer to character_t (may not be null)
 * @param[in] cvarPrefix
 * @sa CL_UGVCvars
 * @sa CL_ActorSelect
 */
static void CL_ActorCvars (const character_t * chr, const char* cvarPrefix)
{
	invList_t *weapon;
	assert(chr);

	/* visible equipment */
	weapon = RIGHT(chr);
	if (weapon)
		Cvar_Set(va("%s%s", cvarPrefix, "rweapon"), weapon->item.t->model);
	else
		Cvar_Set(va("%s%s", cvarPrefix, "rweapon"), "");
	weapon = LEFT(chr);
	if (weapon)
		Cvar_Set(va("%s%s", cvarPrefix, "lweapon"), weapon->item.t->model);
	else
		Cvar_Set(va("%s%s", cvarPrefix, "lweapon"), "");
}
开发者ID:MyWifeRules,项目名称:ufoai-1,代码行数:28,代码来源:cl_team.cpp


示例13: siftDown

/*
* Big O: O(logn)
* Helper function. Helps the remove function maintain the heap structure
* Moves the element downt hrough the heap to the proper location
*/
void siftDown(int index)
{
	int leftChildIndex = LEFT(index); //gets the index of the left child of the element you are trying to fix
	int rightChildIndex = RIGHT(index); // get the index of the right child  of the element you are tyring to fix
	int minIndex; //holds the index of the child with the lower index
	struct tree* tmp; //holds the value of an element for switching
	
	if (rightChildIndex >= heapSize) //if the right child does not exist
	{
		if (leftChildIndex >= heapSize) //if the left child does not exist
			return; //returns nothing. Base case. Node has no children
		else
			minIndex = leftChildIndex; //the min value is leftChild because right child does not exist
	}
	
	//Favors shifting left because if the leftChild is less than or equal to rightChild, it will return leftChild index
	//Will favor swapping left
	else//Both children exist. FAVORS SHIFTING LEFT
	{
		if (getData(heap[leftChildIndex]) <= getData(heap[rightChildIndex])) //If the leftChild is less than or equal to rightChild
			minIndex = leftChildIndex;//the min value is leftChild
		else//if the rightChild is less than the leftChild
			minIndex = rightChildIndex;//the min value is rightChild
	}
	/*
	//FAVORS SHIFTING RIGHT
	//Favors shifting right because if the rightChild is less than or equal to leftChild, it will return rightChild index.
	//The node will then swap with the rightChild index
	else //Both children exist. FAVORS SHIFTING RIGHT
	{
		if (getData(heap[rightChildIndex]) <= getData(heap[leftChildIndex])) //If the rightChild is less than or equal to leftChild
			minIndex = rightChildIndex;//the min value is rightChild
		else//if the leftChild is less than the rightChild
			minIndex = leftChildIndex;//the min value is leftChild
	}
	*/
	if (getData(heap[index]) > getData(heap[minIndex])) //if the data at index is greater than the the minValue of the children
	{
		//switches the parent with the min value
		tmp = heap[minIndex];//holds the minvalue
		heap[minIndex] = heap[index];//parent to minvalue
		heap[index] = tmp;//minvalue to parent
		siftDown(minIndex);//check to make sure the parent is the proper position
	}
}
开发者ID:DerrickChanCS,项目名称:COEN12,代码行数:50,代码来源:huffman.c


示例14: maxHeapify

void maxHeapify(Array &a, int index)
{
    int l = LEFT(index);
    int r = RIGHT(index);
    int largest = 0;
    if (l <= a.length && a[l] > a[index]) {
       largest = l; 
    }else{
        largest = index;
    }
    if (r <= a.length && a[r] > a[largest]) {
       largest = r; 
    }
    if (largest != index) {
       exchange(a[index], a[largest]); 
       maxHeapify(a, largest);
    }
}
开发者ID:LiChenda,项目名称:sorts,代码行数:18,代码来源:heapsort.cpp


示例15: Philosopher

/*
   PROGRAM:  Philosopher
   A program that simulates a philosopher participating in a dining philosophers'
   symposium. Each philosopher will join the symposium, alternating between
   thinking, going hungry and eating a bite, for a number of bites. After he
   has eaten the last bite, he leaves.
*/
int Philosopher(int argl, void* args)
{
    int i,j;
    int bites;			/* Number of bites (mpoykies) */

    assert(argl == sizeof(int[2]));
    i = ((int*)args)[0];
    bites = ((int*)args)[1];

    Mutex_Lock(&mx);		/* Philosopher arrives in thinking state */
    state[i] = THINKING;
    print_state("     %d has arrived\n",i);
    Mutex_Unlock(&mx);

    for(j=0; j<bites; j++) {

        think(i);			/* THINK */

        Mutex_Lock(&mx);		/* GO HUNGRY */
        state[i] = HUNGRY;
        trytoeat(i);		/* This may not succeed */
        while(state[i]==HUNGRY) {
            print_state("     %d waits hungry\n",i);
            Cond_Wait(&mx, &(hungry[i])); /* If hungry we sleep. trytoeat(i) will wake us. */
        }
        assert(state[i]==EATING);
        Mutex_Unlock(&mx);

        eat(i);			/* EAT */

        Mutex_Lock(&mx);
        state[i] = THINKING;	/* We are done eating, think again */
        print_state("     %d is thinking\n",i);
        trytoeat(LEFT(i));		/* Check if our left and right can eat NOW. */
        trytoeat(RIGHT(i));
        Mutex_Unlock(&mx);
    }
    Mutex_Lock(&mx);
    state[i] = NOTHERE;		/* We are done (eaten all the bites) */
    print_state("     %d is leaving\n",i);
    Mutex_Unlock(&mx);

    return i;
}
开发者ID:skyritsis,项目名称:tinyos,代码行数:51,代码来源:mtask.c


示例16: MaxHeapify

void MaxHeapify(int *array, int i, int length) {
  int l = LEFT(i);
  int r = RIGHT(i);
  int largest = i, temp;

  if(l<length && array[l]>array[largest])
    largest = l;

  if(r<length && array[r]>array[largest])
    largest = r;

  if(largest != i) {
    temp = array[i];
    array[i]=array[largest];
    array[largest] = temp;
    MaxHeapify(array, largest, length);
  }
  return;
}
开发者ID:zyongxu,项目名称:codetest,代码行数:19,代码来源:heapsort.cpp


示例17: MAX_HEAPIFY

void MAX_HEAPIFY (heap *A, int i)
{
    int l = LEFT(i);
    int r = RIGHT(i);
    int largest;
    if ((l< A->heap_size) && (A->data[l]>A->data[i]))
        largest = l;
    else
        largest = i;
    if ((r< A->heap_size) && (A->data[r]>A->data[largest]))
        largest = r;
    if (largest != i)
    {
        int tmp = A->data[i];
        A->data[i] = A->data[largest];
        A->data[largest] = tmp;
        MAX_HEAPIFY(A, largest);
    }
}
开发者ID:ganeshkurapati,项目名称:Algorithms-and-Data-Structures,代码行数:19,代码来源:HeapSort.c


示例18: minimum_size

/**
 * Calculate the combined advisory minimum size of all components
 * 
 * @return  Advisory minimum size for the container
 */
static size2_t minimum_size(__this__)
{ 
  itk_component** children = CONTAINER(this)->children;
  long i, n = CONTAINER(this)->children_count;
  size2_t rc;
  rc.width = rc.height = 0;
  rc.defined = true;
  for (i = 0; i < n; i++)
    if ((*(children + i))->visible)
      {
	if (rc.width < (*(children + i))->minimum_size.width)
	  rc.width = (*(children + i))->minimum_size.width;
	if (rc.height < (*(children + i))->minimum_size.height)
	  rc.height = (*(children + i))->minimum_size.height;
      }
  rc.width += LEFT(this) + RIGHT(this);
  rc.height += TOP(this) + BOTTOM(this);
  return rc;
}
开发者ID:maandree,项目名称:itk,代码行数:24,代码来源:margin_layout.c


示例19: G_ReactionFireCheckExecution

/**
 * @brief Check all entities to see whether target has caused reaction fire to resolve.
 * @param[in] target The entity that might be resolving reaction fire
 * @returns whether any entity fired (or would fire) upon target
 * @sa G_ReactionFireOnMovement
 * @sa G_ReactionFirePostShot
 */
static bool G_ReactionFireCheckExecution (const edict_t *target)
{
	edict_t *shooter = NULL;
	bool fired = false;

	/* check all possible shooters */
	while ((shooter = G_EdictsGetNextLivingActor(shooter))) {
		const int tus = G_ReactionFireGetTUsForItem(shooter, target, RIGHT(shooter));
		if (tus > 1) {	/* indicates an RF weapon is there */
			if (G_ReactionFireTargetsExpired(shooter, target, 0)) {
				if (G_ReactionFireTryToShoot(shooter, target)) {
					G_ReactionFireTargetsAdvance(shooter, target, tus);
					fired |= true;
				}
			}
		}
	}
	return fired;
}
开发者ID:MyWifeRules,项目名称:ufoai-1,代码行数:26,代码来源:g_reaction.cpp


示例20: max_heapify

void max_heapify(int *array,int i,int heap_size)
{
    int l = LEFT(i);
    int r = RIGHT(i);
    int largest = i;

    if(l <= heap_size && array[l] > array[i])
        largest = l;
    else if (l <= heap_size && array[r] > array[i])
        largest = r;
    if(largest != i)
    {
        int tmp;
        tmp = array[largest];
        array[largest] = array[i];
        array[i] = tmp;
        max_heapify(array,largest,heap_size);
    }
}
开发者ID:oleeq2,项目名称:trivia,代码行数:19,代码来源:heap_sort.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ RIL_onRequestComplete函数代码示例发布时间:2022-05-30
下一篇:
C++ RIDX函数代码示例发布时间: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