コード例 #1
0
//查找
link searchR(link h, Key v){
	//Key t = key(h->item);
	Key t = h->item;
	link tmp = NULL;
	nr++;
	if (h == z)
		return NULL;
	if eq(v, t)
		return h;
	if less(v, t){
		if ((tmp = searchR(h->l, v)) != NULL){
			h->l = tmp;	h = rotR(h);
		}
		else
			return NULL;
	}
	else{
		if ((tmp = searchR(h->r, v)) != NULL){
コード例 #2
0
ファイル: word.cpp プロジェクト: jakecarlson1/Project01
/*
  The following functions search the GameBoard for the word. A copy of the
  board is saved and then the function begins to search. First the function
  looks for anywhere the first letter of the word appears in the board. The
  folling if-statements only allow the word to search the board if it is within
  the scope of the related search algorithm (if the first letter of the word
  is in the upper left corner of the board, there is no need to search UL, U,
  UR, DL, or L because the word cannot possibly fit in these directions). Once
  the word is found the direction the word was found in is saved and the
  searching stops.
*/
void Word::searchBoard(GameBoard& board)
{
  //a copy of the board is saved
  array = new char*[board.getSize()];
  for(int i = 0; i < board.getSize(); i++)
  {
    array[i] = new char[board.getWidth()];
    strcpy(array[i], board[i]);
  }

  //searching starts
  for(int i = 0; i < board.getSize(); i++)
  {
    for(int j = 0; j < board.getWidth(); j++)
    {
      //if the first letter is found the searching gets more specific
      if(word[0] == array[i][j] && wordFound == 0)
      {
        //all of the following if-statements determine if the first letter is
        //in a place where the folling search function is applicable
        if(i - length >= -1 && j - length >= -1)
          searchUL(i, j);
        if(i - length >= -1)
          searchU(i, j);
        if(i - length >= -1 && board.getWidth() - length >= j)
          searchUR(i, j);
        if(board.getWidth() - length >= j)
          searchR(i, j);
        if(board.getSize() - length >= i && board.getWidth() - length >= j)
          searchDR(i, j);
        if(board.getSize() - length >= i)
          searchD(i, j);
        if(board.getSize() - length >= i && j - length >= -1)
          searchDL(i, j);
        if(j - length >= -1)
          searchL(i, j);
      }
    }
  }
  //deallocates the copy of board
  for(int i = 0; i < board.getSize(); i++)
    delete[] array[i];
  delete[] array;
}
コード例 #3
0
ファイル: abbs.c プロジェクト: renatocf/MAC0323
static Item searchR(link h, key v)
{
    Key t = key(h->item);
    if(h == z) return NULLitem;
    if(eq(v,t)) return h->item;
    if(less(v,t)) return searcR(h->l,v);
    else return searchR(h->r,v);
    /* Algoritmo recursivo para busca:
     *
     *      |---------------|
     *      |      ( )      | Vamos olhando o valor
     *      |      / \      | de cada um, a partir
     *      |     /   \     | da raiz, e dividindo
     *      |    /     \    | para uma das subárvores
     *      |-------|-------| conforme o valor.
     *      |  ( )  |  ( )   
     *      |  / \  |  / \   
     *      |---|---| /   \  
     *       [z]|[z]|[z] [z] 
     *          |---|          
     */
}
コード例 #4
0
ファイル: topdownRB.c プロジェクト: snidell/CSE2320
Item STsearch(Key v) 
{
return searchR(head, v);
}
コード例 #5
0
ファイル: dst.cpp プロジェクト: GaZpaR/self-education
	T search(key v){
		return searchR(head, v, 0);
	}
コード例 #6
0
ファイル: avl.c プロジェクト: manuelsousa7/iaed-hashtags
/******************************************************************************************
* AVLprocura()
*
* Arguments:    head:   ponteiro para a cabeca da arvore AVL
*               v:      key a procurar na arvore
*
* Returns: Item - retorna um Item se este for encontrado, senao retorna NULLitem
*
* Description:  chama funcao de procura na arvore
*****************************************************************************************/
Item AVLprocura(link head, Key v){
    return searchR(head, v);
}
コード例 #7
0
ファイル: link.c プロジェクト: ZoneMo/backup
Item searchR(link t, Key v)
  { 
    if (t == z) return NULLitem;
    if (eq(key(t->item), v)) return t->item;
    return searchR(t->next, v);
  }
コード例 #8
0
ファイル: ARNE.c プロジェクト: vinivendra/MAC0323-ED-3
Item *STsearch(Key v, link head) {
    return searchR(head, v);
}
コード例 #9
0
ファイル: t2enc.c プロジェクト: ruan0408/EP4-ED
/*Função envelope*/
Item_lema st_lema_search(Key_lema v)
{
    return searchR(heads[hash(v, M)], v);
}
コード例 #10
0
ファイル: t2enc.c プロジェクト: ruan0408/EP4-ED
/*Procura chave na tabela*/
static Item_lema searchR(link t, Key_lema v)
{
    if (t == z) return NULLitem_lema;
    if (eq_lema(key_lema(t->item), v)) return t->item;
    return searchR(t->next, v);
}
コード例 #11
0
Item STsearch (Key searchKey) { 
  return searchR (rootNodeLink, searchKey); 
}