コード例 #1
0
void Astar::starseach(int fid)
{
	int col = ((AstarItem *)close->objectAtIndex(fid))->getcol();
	int row = ((AstarItem *)close->objectAtIndex(fid))->getrow();
    //搜索目前点的上下左右四个方向
	int mycol = col;
	int myrow = row - 1;
	if(myrow >= 0 && checkmap(mycol,myrow)){
		if(checkOpen(mycol,myrow,fid) && checkclose(mycol,myrow)){
		   addtoopen(mycol,myrow,fid);
		}
	}
	mycol = col - 1;
	myrow = row;
	if(mycol >= 0 && checkmap(mycol,myrow)){
		if(checkOpen(mycol,myrow,fid) && checkclose(mycol,myrow)){
		   addtoopen(mycol,myrow,fid);
		}
	}
	mycol = col;
	myrow = row + 1;
	if(myrow < map->getMapSize().width && checkmap(mycol,myrow)){
		if(checkOpen(mycol,myrow,fid) && checkclose(mycol,myrow)){
		   addtoopen(mycol,myrow,fid);
		}
	}
	mycol = col + 1;
	myrow = row;
	if(mycol < map->getMapSize().height && checkmap(mycol,myrow)){
		if(checkOpen(mycol,myrow,fid) && checkclose(mycol,myrow)){
		   addtoopen(mycol,myrow,fid);
		}
	}
}
コード例 #2
0
ファイル: fauxPq.c プロジェクト: KeithLatteri/awips2
/*
 * Steps thru the time-sorted inventory of products according to 'mt', and
 * the current cursor value.  If no product in the inventory matches the
 * specification, then PQUEUE_END is returned; otherwise, if a matching
 * product is found, then ifMatch(xprod, len, otherargs) is called and the
 * return value of that function is returned.
 *
 * Whether or not a matching product is found depends upon the configuration
 * file.
 *
 * pq               The product queue.  (in)
 * mt               The time-matching criteria for finding a product. (in)
 * clss             The class of products to find. (in)
 * ifMatch          The function to call if a matching product is found. (in)
 * otherargs        The last argument to (*ifMatch).  (unknown)
 *
 * Returns:
 *   pq.h:PQUEUE_END  if no matching product was found.
 *   errno.h:EINVAL   if the queue is NULL or not open.
 *   (else)           <errno.h> error code.
 */
int pq_sequence(
    pqueue*           pq,
    pq_match          mt,
    const prod_class_t* clss,
    pq_seqfunc*       ifMatch,
    void*             otherargs)
{
    int              status = checkOpen(pq);

    if (status == ENOERR) {
        prod_info   info;   /* the product metadata */
        void*       datap;  /* the XDR-decoded product-data */
                            /* (excludes metadata) */
        void*       xprodp; /* the corresponding, XDR-encoded product */
                            /* (includes metadata) */
        size_t      len;    /* the size of xprodp in bytes */

        status = cfGetProduct(mt, clss, &info, &datap, &xprodp, &len);

        if (status == ENOERR) {
            status = (*ifMatch)(&info, datap, xprodp, len, otherargs);

            cfFreeProduct(&info, &datap, &xprodp);
        }
    }

    return status;
}
コード例 #3
0
ファイル: fauxPq.c プロジェクト: KeithLatteri/awips2
/*
 * Reserves space in the product queue for a product.  This function is used
 * when a product is not yet assem- bled but we wish to allocate storage in
 * the queue for its assembly, such as upon the receipt of a COMINGSOON remote
 * procedure call in the server.  It returns storage in *ptrp suitable for
 * placing the data of the product described by infop and product_size.  The
 * value of *indexp should be retained for use in committing the product using
 * pqe_insert() or abandoning it using pqe_discard().  Calls to this function
 * for products whose signature is already in the queue fail with an error
 * indication of PQUEUE_DUP.
 *
 * This implementation just checks the arguments and returns allocated space 
 * for the product.
 *
 * pq                The product queue. (in)
 * infop             Information on the product. (in)
 * ptrp              Where to copy the data portion of the product. Managed by
 *                   this module. (out)
 * indexp            The index of the product for use by pqe_insert() or
 *                   pqe_discard(). (out)
 *
 * Returns:
 *   pq.h:ENOERR     if success.
 *   pq.h:PQUEUE_DUP if a product with same signature is already in the queue.
 *   errno.h:ENOMEM  if out of memory.
 *   errno.h:EINVAL  if any argument is NULL or the queue is not open.
 */
int pqe_new(
    pqueue*          pq,
    const prod_info* infop,
    void**           ptrp,
    pqe_index*       indexp)
{
    int              status = checkOpen(pq);

    if (status == ENOERR) {
        if (infop == NULL || ptrp == NULL || indexp == NULL) {
            status = EINVAL;
        }
        else {
            void*            ptr = malloc(infop->sz);

            if (ptr == NULL) {
                status = ENOMEM;
            }
            else {
                *ptrp = ptr;
                indexp->offset = (off_t)ptr;
                (void)memcpy(indexp->signature, infop->signature, 
                    sizeof(infop->signature));
                status = ENOERR;
            }
        }
    }

    return status;
}
コード例 #4
0
ファイル: fauxPq.c プロジェクト: KeithLatteri/awips2
/*ARGSUSED1*/
int pq_insert(
    pqueue*        pq,
    const product* prod)
{
    assert(pq != NULL);

    return checkOpen(pq);
}
コード例 #5
0
ファイル: Astar.cpp プロジェクト: suli1/suli1-myGame
void Astar::starSearch(int fid)
{
    auto item = (AstarItem*)_close->getObjectAtIndex(fid);
    int col = item->getCol();
    int row = item->getRow();

    // 搜索目前的点的上,下,左,右四个方向

    // 下
    int mycol = col;
    int myrow = row - 1;
    if(myrow >= 0 && checkMap(mycol, myrow)) {
        if(checkOpen(mycol, myrow, fid) && checkClose(mycol, myrow)) {
            addToOpen(mycol, myrow, fid);
        }
    }

    // 左
    mycol = col - 1;
    myrow = row;
    if(mycol >= 0 && checkMap(mycol, myrow)) {
        if(checkOpen(mycol, myrow, fid) && checkClose(mycol, myrow)) {
            addToOpen(mycol, myrow, fid);
        }
    }

    // 上
    mycol = col;
    myrow = row + 1;
    if(myrow < _map->getMapSize().height && checkMap(mycol, myrow)) {
        if(checkOpen(mycol, myrow, fid) &&checkClose(myrow, myrow)) {
            addToOpen(mycol, myrow, fid);
        }
    }

    // 右
    mycol = col + 1;
    myrow = row;
    if(mycol < _map->getMapSize().height && checkMap(mycol, myrow)) {
        if(checkOpen(mycol, myrow, fid) &&checkClose(myrow, myrow)) {
            addToOpen(mycol, myrow, fid);
        }
    }

}
コード例 #6
0
ファイル: fauxPq.c プロジェクト: KeithLatteri/awips2
/*ARGSUSED*/
int pq_seqdel(
    pqueue*           pq,
    pq_match          mt,
    const prod_class_t* clss,
    int               wait,
    size_t*           extentp,
    timestampt*       timestampp) 
{
    return checkOpen(pq);
}
コード例 #7
0
ファイル: file2.c プロジェクト: DanielTillett/splint
int main (void)
{
  FILE *fle1 = fopen ("test1", "r");

  if (fle1 == NULL)
    {
      FILE *fle2 = fopen ("test2", "r");
      checkOpen (fle2);
    } /* fle2 not closed */
  
  return 0; /* fle1 not closed */
} 
コード例 #8
0
ファイル: fauxPq.c プロジェクト: KeithLatteri/awips2
/*
 * Abandons the saving of a product which was begun using pqe_new() and
 * releases any allocated resources.
 *
 * pq                The product queue. (in/out)
 * index             The index of the product begun by pqe_new(...). (in)
 *
 * Returns:
 *   pq.h:ENOERR     if success.
 *   errno.h:EINVAL  if the queue is NULL or not open.
 */
int pqe_discard(
    pqueue*   pq,
    pqe_index index)
{
    int status = checkOpen(pq);

    if (status == ENOERR) {
        if(!pqeIsNone(index))
            free((void*)index.offset);
    }

    return status;
}
コード例 #9
0
ファイル: file1.c プロジェクト: DanielTillett/splint
int main (void)
{
  FILE *fle = NULL;
  char s[10];

  checkClosed (fle); /* okay */
  checkOpen (fle); /* error */

  fle = fopen ("test", "r");

  if (fle == NULL) 
    {
      return 0;
    }

  checkClosed (fle); /* error */
  checkOpen (fle); /* okay */

  (void) fclose (fle);
  checkOpen (fle); /* error */
  checkClosed (fle); /* okay */

  return 0; 
}