示例#1
0
文件: timer.cpp 项目: ukaea/epics
void Timer::addElement(TimerCallbackPtr const & timerCallback)
{
    timerCallback->onList = true;
    if(head.get()==NULL) {
        head = timerCallback;
        timerCallback->next.reset();
        return;
    }
    TimerCallbackPtr nextNode(head);
    TimerCallbackPtr prevNode;
    while(true) {
        if(timerCallback->timeToRun < nextNode->timeToRun) {
            if(prevNode.get()!=NULL) {
                prevNode->next = timerCallback;
            } else {
                head = timerCallback;
            }
            timerCallback->next = nextNode;
            return;
        }
        if(nextNode->next.get()==NULL) {
            nextNode->next = timerCallback;
            timerCallback->next.reset();
            return;
        }
        prevNode = nextNode;
        nextNode = nextNode->next;
    }
}
示例#2
0
// Retrieve the index of the midnode of an edge, if it exists
int OctreeGrid::getMidEdgeNode(int node1, int node2, int axis) const {
	const Node &n1 = m_Nodes[node1];
	const Node &n2 = m_Nodes[node2];
	oct_debug(n1.position[axis] < n2.position[axis]);
	if (n1.next(axis) == node2) {
		oct_debug(n2.prev(axis) == node1);
		return -1;
	} else {
		const int c1 = n1.position[axis];
		const int c2 = n2.position[axis];
		const int c3 = (c1 + c2) / 2;
		oct_debug((c1 + c2) % 2 == 0);
		int m1 = n1.next(axis);
		int m2 = n2.prev(axis);
		while (m_Nodes[m1].position[axis] != c3 && m_Nodes[m2].position[axis] != c3) {
			m1 = nextNode(m1, axis);
			m2 = prevNode(m2, axis);
			oct_debug(m1 != -1 && m2 != -1);
			oct_debug(m1 != node2 && m2 != node1);
		}
		if (m_Nodes[m1].position[axis] == c3) {
			return m1;
		} else {
			return m2;
		}
	}
}
示例#3
0
const Path&
OccupancyMap::prepareShortestPaths(double x, double y,
                                   double min_distance, double max_distance,
                                   double max_occ_dist,
                                   bool allow_unknown) {
  endpoints_.clear();

  if (map_ == NULL) {
    ROS_WARN("OccupancyMap::prepareShortestPaths() Map not set");
    return endpoints_;
  }

  if (map_->max_occ_dist < max_occ_dist) {
    ROS_ERROR("OccupancyMap::prepareShortestPaths() CSpace has been calculated "
              "up to %f, but max_occ_dist=%.2f",
              map_->max_occ_dist, max_occ_dist);
    ROS_BREAK();
  }

  initializeSearch(x, y);

  Node curr_node;
  while (nextNode(max_occ_dist, &curr_node, allow_unknown)) {
    double node_dist = curr_node.true_cost * map_->scale;
    if (min_distance <= node_dist && node_dist < max_distance) {
      float x = MAP_WXGX(map_, curr_node.coord.first);
      float y = MAP_WYGY(map_, curr_node.coord.second);
      endpoints_.push_back(Eigen::Vector2f(x, y));
    } else if (node_dist > max_distance) {
      break;
    }
  }
  return endpoints_;
}
void DOMNodeIteratorImpl::removeNode (DOMNode* node) {
	if (fDetached)
		throw DOMException(DOMException::INVALID_STATE_ERR, 0, GetDOMNodeIteratorMemoryManager);

    // Implementation note: Fix-up means setting the current node properly
    // after a remove.

    if (!node) return;

    DOMNode* deleted = matchNodeOrParent(node);

    if (!deleted) return;

    if (fForward) {
        fCurrentNode = previousNode(deleted);
    } else
    // if (!fForward)
    {
        DOMNode* next = nextNode(deleted, false);
        if (next != 0) {
            // normal case: there _are_ nodes following this in the iterator.
            fCurrentNode = next;
        } else {
            // the last node in the iterator is to be removed,
            // so we set the current node to be the previous one.
            fCurrentNode = previousNode(deleted);
            fForward = true;
        }

    }

}
void AssetImporter::importScene(
    ID3D11Device* d3dDevice,
    std::wstring& path,
    GRAPHICS::Scene& outScene
)
{
    Assimp::Importer importer;
    std::string assetPath(path.begin(), path.end());
    const aiScene* scene = importer.ReadFile(assetPath.c_str(),
                           aiProcess_ConvertToLeftHanded |
                           aiProcess_CalcTangentSpace |
                           aiProcess_Triangulate |
                           aiProcess_JoinIdenticalVertices |
                           aiProcess_FlipWindingOrder |
                           aiProcess_GenUVCoords |
                           aiProcess_GenSmoothNormals |
                           aiProcess_SortByPType);

    if (!scene)
    {
        printf("Failed to import asset: %s", assetPath.c_str());
    }

    GRAPHICS::RESOURCES::Mesh* meshArr = loadMeshes(d3dDevice, scene);
    GRAPHICS::RESOURCES::Material* materialArr = loadMaterials(d3dDevice, scene);

    nextNode(d3dDevice, scene, scene->mRootNode, scene->mRootNode->mTransformation, meshArr, materialArr, outScene);

    loadLights(d3dDevice, outScene, scene);

    delete[] meshArr;
    delete[] materialArr;
}
示例#6
0
// Return true iff the cell cellId is 2:1 graded
bool OctreeGrid::cellIs2to1Graded(int cellId) const {
	const Cell &cell = m_Cells[cellId];
	const int v0 = cell.corner(CORNER_X0_Y0_Z0);
	const int v1 = cell.corner(CORNER_X1_Y0_Z0);
	const int v2 = cell.corner(CORNER_X1_Y1_Z0);
	const int v3 = cell.corner(CORNER_X0_Y1_Z0);
	const int v4 = cell.corner(CORNER_X0_Y0_Z1);
	const int v5 = cell.corner(CORNER_X1_Y0_Z1);
	const int v6 = cell.corner(CORNER_X1_Y1_Z1);
	const int v7 = cell.corner(CORNER_X0_Y1_Z1);
	auto testEdge = [this] (int a, int b, int axis) {
		return (nextNode(a, axis) == b || nextNode(a, axis) == prevNode(b, axis));
	};
	return testEdge(v0, v1, X) && testEdge(v3, v2, X) && testEdge(v4, v5, X) && testEdge(v7, v6, X)
		&& testEdge(v0, v3, Y) && testEdge(v1, v2, Y) && testEdge(v4, v7, Y) && testEdge(v5, v6, Y)
		&& testEdge(v0, v4, Z) && testEdge(v1, v5, Z) && testEdge(v3, v7, Z) && testEdge(v2, v6, Z);
}
示例#7
0
bool 
DL_detect::nextNode(uint64_t txnid, DetectData * detect_data) {
	int thd = get_thdid_from_txnid(txnid);
	assert( !detect_data->visited[thd] );
	detect_data->visited[thd] = true;
	detect_data->recStack[thd] = true;
	
	pthread_mutex_lock( &dependency[thd].lock );
	
	int lock_num = dependency[thd].num_locks;
	int txnid_num = dependency[thd].adj.size();
	uint64_t txnids[ txnid_num ];
	int n = 0;
	
	if (dependency[thd].txnid != (SInt64)txnid) {
		detect_data->recStack[thd] = false;
		pthread_mutex_unlock( &dependency[thd].lock );
		return false;
	}
	
	for(list<uint64_t>::iterator i = dependency[thd].adj.begin(); i != dependency[thd].adj.end(); ++i) {
		txnids[n++] = *i;
	}
	
	pthread_mutex_unlock( &dependency[thd].lock );

	for (n = 0; n < txnid_num; n++) {
		int nextthd = get_thdid_from_txnid( txnids[n] );

		// next node not visited and txnid is not stale
		if ( detect_data->recStack[nextthd] ) {
			if ((SInt32)txnids[n] == dependency[nextthd].txnid) {
				detect_data->loop = true;
				detect_data->onloop = true;
				detect_data->loopstart = nextthd;
				break;
			}
		} 
		if ( !detect_data->visited[nextthd] && 
			dependency[nextthd].txnid == (SInt64) txnids[n] && 
			nextNode(txnids[n], detect_data)) 
		{
			break;
		}
	}
	detect_data->recStack[thd] = false;
	if (detect_data->loop 
			&& detect_data->onloop 
			&& lock_num < detect_data->min_lock_num) {
		detect_data->min_lock_num = lock_num;
		detect_data->min_txnid = txnid;
	}
	if (thd == detect_data->loopstart) {
		detect_data->onloop = false;
	}
	return detect_data->loop;
}
示例#8
0
int main(int argc, char *argv[])
{
    struct node node_1 = {'a', NULL};
    struct node node_2 = {'b', NULL};
    struct node node_3 = {'c', NULL};
    struct node node_4 = {'d', NULL};
    struct node node_5 = {'e', NULL};
    struct node* temporaryNode = NULL;
    struct node* iteratorNode = NULL;
    int count = 1;
    struct node*  dynamicNode = NULL;

    printf("Static Linked List funcitons\n");
    insertNode(&node_1, &node_2);
    insertNode(&node_1, &node_3);
    insertNode(&node_1, &node_4);
    insertNode(&node_1, &node_5);

    iteratorNode = &node_1; 
    do {
        temporaryNode = iteratorNode;
        iteratorNode = nextNode(temporaryNode);
        printf("node[%d].value = %c\n", count, temporaryNode->value);
        count++;
    } while(temporaryNode != iteratorNode); 

    printf("Dynamic Linked List functions\n");

    dynamicNode = createNode('1');
    printf("dynamicList at %p\n", dynamicNode);
    printf("dynamicNode.value: %c\n", dynamicNode->value);

    dynamicNode->next = createNode('2');
    temporaryNode = getLastNode(dynamicNode);
    printf("temporaryNode at %p\n", temporaryNode);
    printf("lastNode.value: %c\n", temporaryNode->value);

    temporaryNode->next = createNode('3');
    temporaryNode = getLastNode(dynamicNode);
    printf("temporaryNode at %p\n", temporaryNode);
    printf("lastNode.value: %c\n", temporaryNode->value);

    temporaryNode->next = createNode('4');
    temporaryNode = getLastNode(dynamicNode);
    printf("temporaryNode at %p\n", temporaryNode);
    printf("lastNode.value: %c\n", temporaryNode->value);

    destructLastNode(dynamicNode);
    temporaryNode = getLastNode(dynamicNode);
    printf("temporaryNode at %p\n", temporaryNode);
    printf("lastNode.value: %c\n", temporaryNode->value);

    printf("total of nodes %d\n", allocatedNodes.count);
    destructList(dynamicNode); //frees the linked list
    printf("total of nodes %d\n", allocatedNodes.count);
    forceUnregisterAllNodes();//frees all the nodes allocated
}
示例#9
0
Node* ListOrganizer::findInList(List *p, std::string n) {
	Node *q;
	q = p->front;
	while (q != NULL) {
		if (q->data == n)
			break;
		q = nextNode(q);
	}
	return q;
}
示例#10
0
void OctreeGrid::assertIsValid() {
	// Check node adjacency relations
	for (int node1 = 0; node1 < (int) m_Nodes.size(); ++node1) {
		for (int axis = 0; axis < 3; ++axis) {
			int node0 = prevNode(node1, axis);
			int node2 = nextNode(node1, axis);
			if (m_Nodes[node1].position[axis] == 0) {
				oct_debug(node0 == -1);
			} else if (node0 != -1) {
				oct_debug(nextNode(node0, axis) == node1);
			}
			if (m_Nodes[node1].position[axis] == m_CellGridSize[axis]) {
				oct_debug(node2 == -1);
			} else if (node2 != -1) {
				oct_debug(prevNode(node2, axis) == node1);
			}
		}
	}
	// Check cell adjacency relations
	for (int cell1 = 0; cell1 < (int) m_Cells.size(); ++cell1) {
		for (int axis = 0; axis < 3; ++axis) {
			int cell0 = prevCell(cell1, axis);
			int cell2 = nextCell(cell1, axis);
			if (cellCornerPos(cell1, CORNER_X0_Y0_Z0)[axis] == 0) {
				oct_debug(cell0 == -1);
			} else {
				oct_debug(cell0 != -1);
				if (cellExtent(cell1) == cellExtent(cell0)) {
					oct_debug(nextCell(cell0, axis) == cell1);
				}
			}
			if (cellCornerPos(cell1, CORNER_X1_Y1_Z1)[axis] == m_CellGridSize[axis]) {
				oct_debug(cell2 == -1);
			} else {
				oct_debug(cell2 != -1);
				if (cellExtent(cell1) == cellExtent(cell2)) {
					oct_debug(prevCell(cell2, axis) == cell1);
				}
			}
		}
	}
}
示例#11
0
void makeMove(binaryTreePtr tree, infoPtr gameInfo)
/* This procedure will make the best move available
 * Pre-condition: none
 * Post-condition: the best move has been made
*/
{
	//go to the root
	nextNode(tree, TOROOT);
	//get the info for root/the top level
	infoPtr root = retrieveNodeElm(tree);
	//goto first node of next level
	nextNode(tree, TOLEFT);
	//get the info for this node
	infoPtr temp = retrieveNodeElm(tree);

	//is this the value on this level that gave root it's value?
	if (root->eval == temp->eval)
	{
		//it is! Then copy the game area to root
		copyGameArea(temp, root);
	}else
	{
		//is there a next node on this level and is the current node's value not
		//equal to the root's?
		while ((existNode(tree,TORIGHT) == 1) && (root->eval != temp->eval))
		{
			//goto next node on level
			nextNode(tree, TORIGHT);
			//get the info for this node
			temp = retrieveNodeElm(tree);
			//is this the value on this level that gave root it's value?
			if (root->eval == temp->eval)
			{
				//it is! Then copy the game area to root
				copyGameArea(temp, root);
			}
		}
	}

	//copy the playArea from the root to the game's playArea
	copyGameArea(root,gameInfo);
}
示例#12
0
struct node* getLastNode(struct node* listStart)
{
    struct node* seekNode = listStart; 
    struct node* temporaryNode = NULL; 

    do {
        temporaryNode = seekNode;
        seekNode = nextNode(seekNode);
    } while( seekNode != temporaryNode); 
    return seekNode;
}    
示例#13
0
TER PathCursor::reverseLiquidity () const
{
    // Every account has a transfer rate for its issuances.

    // TOMOVE: The account charges
    // a fee when third parties transfer that account's own issuances.

    // node.transferRate_ caches the output transfer rate for this node.
    node().transferRate_ = amountFromRate (
        rippleTransferRate (view(), node().issue_.account));

    if (node().isAccount ())
        return reverseLiquidityForAccount ();

    // Otherwise the node is an Offer.
    if (isXRP (nextNode().account_))
    {
        WriteLog (lsTRACE, RippleCalc)
            << "reverseLiquidityForOffer: "
            << "OFFER --> offer: nodeIndex_=" << nodeIndex_;
        return tesSUCCESS;

        // This control structure ensures deliverNodeReverse is only called for the
        // rightmost offer in a chain of offers - which means that
        // deliverNodeReverse has to take all of those offers into consideration.
    }

    // Next is an account node, resolve current offer node's deliver.
    STAmount saDeliverAct;

    WriteLog (lsTRACE, RippleCalc)
        << "reverseLiquidityForOffer: OFFER --> account:"
        << " nodeIndex_=" << nodeIndex_
        << " saRevDeliver=" << node().saRevDeliver;

    // The next node wants the current node to deliver this much:
    return deliverNodeReverse (
        nextNode().account_,
        node().saRevDeliver,
        saDeliverAct);
}
示例#14
0
// Create a new double-link adjacency relation along axis
void OctreeGrid::createNodeLinks(int node1, int node2, int axis) {
	oct_debug(node1 != -1 && node2 != -1);
	if (nextNode(node1, axis) == -1) {
		oct_debug(prevNode(node2, axis) == -1);
		m_Nodes[node1].setNext(axis, node2);
		m_Nodes[node2].setPrev(axis, node1);
		for (int c = 0; c < 3; ++c) {
			if (c == axis) { continue; }
			oct_debug(m_Nodes[node1].position[c] == m_Nodes[node2].position[c]);
		}
	}
}
void WaitForEventNode::execute(){


        if (sceneData->controller->eventTrigger.size()>0){
            for (int i=0;i<(int)sceneData->controller->eventTrigger.size();i++){
                if (sceneData->controller->eventTrigger[i]==eventName){
                    cout << "triggered Event: " << eventName << endl;
                    nextNode();
                }
            }
        }
}
示例#16
0
int ZXMLDoc::getChildByName(const char* name)
{
	//if(isEmpty() == 1) return 0;
	
	cur = cur->xmlChildrenNode;
	while (isLastNode() != 1) 
	{
		if ((!xmlStrcmp(cur->name, (const xmlChar *)name))) return 1;
		nextNode();
	}
	return 0;
}
示例#17
0
List* ListOrganizer::clearList(List *p) {
	Node *q, *w;
	q = p->front;
	while (q != NULL) {
		w = nextNode(q);
		freeNode(q);
		q = w;
	}
	p->front = NULL;
	p->rear = NULL;
	return p;
}
示例#18
0
/**
 *  Performs the iteration of BRUE
 */
void performIteration(treeNode* root,  int switchingPoint, heuristics_t heuristic, int budget){
	int level = 0; 
	treeNode* n = root, *leaf = NULL;
	while (n != NULL && n->n>0){
		leaf = n;
		POLICY p = level < switchingPoint ? EXPLORATION : EXPLOITATION;
		n = nextNode(n,p);	
		level++;
	}
	double reward = getReward(leaf, heuristic, budget);
	backpropagate(leaf, reward);
} 
void SwitchCameraNode::execute(){
    sceneData->controller->controlledActor=cameraActor;

    controller->switchTool(TOOL_NAV);
    sceneData->updateView();
    CameraActor* cA=dynamic_cast<CameraActor*>(cameraActor);
    if (cA){
        renderer->fov=cA->fov;
        cA->bCameraShake=bCameraShake;
    }
    renderer->focus=focus;
    nextNode();
}
void StopAnimNode::execute(){

    Character* myChar=NULL;
    myChar=dynamic_cast<Character*>(applyTo);
    if (!myChar)
        cout << "not assigned to character!" << endl;

    if (myChar){
        myChar->stopAnim();
    }

    nextNode();
}
示例#21
0
PassRefPtr<Node> Text::mergeNextSiblingNodesIfPossible()
{
    RefPtr<Node> protect(this);

    // Remove empty text nodes.
    if (!length()) {
        // Care must be taken to get the next node before removing the current node.
        RefPtr<Node> nextNode(NodeTraversal::nextPostOrder(*this));
        remove(IGNORE_EXCEPTION);
        return nextNode.release();
    }

    // Merge text nodes.
    while (Node* nextSibling = this->nextSibling()) {
        if (nextSibling->nodeType() != TEXT_NODE)
            break;

        RefPtr<Text> nextText = toText(nextSibling);

        // Remove empty text nodes.
        if (!nextText->length()) {
            nextText->remove(IGNORE_EXCEPTION);
            continue;
        }

        // Both non-empty text nodes. Merge them.
        unsigned offset = length();
        String nextTextData = nextText->data();
        String oldTextData = data();
        setDataWithoutUpdate(data() + nextTextData);
        updateTextRenderer(oldTextData.length(), 0);

        // Empty nextText for layout update.
        nextText->setDataWithoutUpdate(emptyString());
        nextText->updateTextRenderer(0, nextTextData.length());

        document().didMergeTextNodes(nextText.get(), offset);

        // Restore nextText for mutation event.
        nextText->setDataWithoutUpdate(nextTextData);
        nextText->updateTextRenderer(0, 0);

        document().incDOMTreeVersion();
        didModifyData(oldTextData);
        nextText->remove(IGNORE_EXCEPTION);
    }

    return NodeTraversal::nextPostOrder(*this);
}
示例#22
0
// Add a node at the middle of an edge
int OctreeGrid::addMidEdgeNode(int node1, int node2, int axis) {
	oct_debug(node1 != -1 && node2 != -1);
	oct_debug(nextNode(node1, axis) == node2);
	oct_debug(prevNode(node2, axis) == node1);

	// Setup node position
	Node newNode;
	newNode.position = m_Nodes[node1].position;
	newNode.position[axis] = (m_Nodes[node1].position[axis] + m_Nodes[node2].position[axis]) / 2;
	oct_debug((m_Nodes[node1].position[axis] + m_Nodes[node2].position[axis]) % 2 == 0);

	// Setup node adjacency
	int newId = (int) m_Nodes.size();
	m_Nodes.emplace_back(newNode);
	updateNodeLinks(node1, node2, newId, axis);
	return newId;
}
示例#23
0
Path OccupancyMap::astar(double startx, double starty,
                                double stopx, double stopy,
                                double max_occ_dist /* = 0.0 */,
                                bool allow_unknown /* = false */) {
  Path path;

  if (map_ == NULL) {
    ROS_WARN("OccupancyMap::astar() Map not set");
    return path;
  }

  int stopi = MAP_GXWX(map_, stopx), stopj = MAP_GYWY(map_, stopy);
  if (!MAP_VALID(map_, stopi ,stopj)) {
    ROS_ERROR("OccupancyMap::astar() Invalid stopping position");
    ROS_BREAK();
  }
  if (map_->max_occ_dist < max_occ_dist) {
    ROS_ERROR("OccupancyMap::astar() CSpace has been calculated up to %f, "
              "but max_occ_dist=%.2f",
              map_->max_occ_dist, max_occ_dist);
    ROS_BREAK();
  }

  initializeSearch(startx, starty);
  // Set stop to use heuristic
  stopi_ = stopi;
  stopj_ = stopj;

  bool found = false;
  Node curr_node;
  while (nextNode(max_occ_dist, &curr_node, allow_unknown)) {
    if (curr_node.coord.first == stopi && curr_node.coord.second == stopj) {
      found = true;
      break;
    }
  }

  // Recreate path
  if (found) {
    buildPath(stopi, stopj, &path);
  }
  return Path(path.rbegin(), path.rend());
}
示例#24
0
DOM_Node NodeIteratorImpl::nextNode () {
	if (fDetached)
		throw DOM_DOMException(DOM_DOMException::INVALID_STATE_ERR, null);

	DOM_Node result;

    // if root is null there is no next node.
    if (fRoot.isNull())
			return result;

    DOM_Node aNextNode = fCurrentNode;
    bool accepted = false; // the next node has not been accepted.

    while (!accepted) {

        // if last direction is not forward, repeat node.
        if (!fForward && !aNextNode.isNull()) {
            //System.out.println("nextNode():!fForward:"+fCurrentNode.getNodeName());
            aNextNode = fCurrentNode;
        } else {
        // else get the next node via depth-first
            aNextNode = nextNode(aNextNode, true);
        }

        fForward = true; //REVIST: should direction be set forward before null check?

        // nothing in the list. return null.
        if (aNextNode.isNull())
					return result;

        // does node pass the filters and whatToShow?
        accepted = acceptNode(aNextNode);
        if (accepted) {
            // if so, then the node is the current node.
            fCurrentNode = aNextNode;
            return fCurrentNode;
				}

    }

    // no nodes, or no accepted nodes.
    return result;
}
示例#25
0
QString RuntimeInfo::setState( NetworkSetup * NC,
                               Action_t A,
                               bool Force ) {
    QString M;
    RuntimeInfo * Deeper = nextNode();

    if( Deeper ) {
      // first go deeper
      M = Deeper->setState( NC, A, Force );
      if( ! M.isEmpty() )
        return M;
    }

    // set my own state
    Log (( "-> Act upon %s\n", netNode()->name() ));
    M = setMyState( NC, A, Force );
    Log (( "   result %s\n", M.latin1() ));
    return M;
}
void MorphSpriteMeshNode::execute(){

        if (morphOne->particleScale>0.0)
            morphOne->particleScale-=morphRate;

        if (morphOne->particleAngleScale>0.0)
            morphOne->particleAngleScale-=morphAngleRate;

        if (morphTwo->particleScale<particleScaleTwo)
            morphTwo->particleScale+=morphRate;

        if (morphTwo->particleAngleScale<particleAngleScaleTwo)
            morphTwo->particleAngleScale+=morphAngleRate;

        if (morphOne->particleScale<0.0 &&
            morphOne->particleAngleScale<0.0 &&
            morphTwo->particleScale>particleScaleTwo &&
            morphTwo->particleAngleScale>particleAngleScaleTwo)
            nextNode();
}
DOMNode* DOMNodeIteratorImpl::nextNode () {
	if (fDetached)
		throw DOMException(DOMException::INVALID_STATE_ERR, 0, GetDOMNodeIteratorMemoryManager);

    // if root is 0 there is no next node->
    if (!fRoot)
			return 0;

    DOMNode* aNextNode = fCurrentNode;
    bool accepted = false; // the next node has not been accepted.

    while (!accepted) {

        // if last direction is not forward, repeat node->
        if (!fForward && (aNextNode != 0)) {
            //System.out.println("nextNode():!fForward:"+fCurrentNode.getNodeName());
            aNextNode = fCurrentNode;
        } else {
        // else get the next node via depth-first
            aNextNode = nextNode(aNextNode, true);
        }

        fForward = true; //REVIST: should direction be set forward before 0 check?

        // nothing in the list. return 0.
        if (!aNextNode) return 0;

        // does node pass the filters and whatToShow?
        accepted = acceptNode(aNextNode);
        if (accepted) {
            // if so, then the node is the current node->
            fCurrentNode = aNextNode;
            return fCurrentNode;
        }
    }

    // no nodes, or no accepted nodes.
    return 0;
}
示例#28
0
void OccupancyMap::prepareAllShortestPaths(double x, double y,
                                           double max_occ_dist,
                                           bool allow_unknown) {
  if (map_ == NULL) {
    ROS_WARN("OccupancyMap::prepareAllShortestPaths() Map not set");
    return;
  }

  if (map_->max_occ_dist < max_occ_dist) {
    ROS_ERROR("OccupancyMap::shortestToDests() CSpace has been calculated "
              "up to %f, but max_occ_dist=%.2f",
              map_->max_occ_dist, max_occ_dist);
    ROS_BREAK();
  }

  initializeSearch(x, y);

  Node curr_node;
  while (nextNode(max_occ_dist, &curr_node, allow_unknown)) {
    ;
  }
}
示例#29
0
文件: timer.cpp 项目: ukaea/epics
void Timer::cancel(TimerCallbackPtr const &timerCallback)
{
    Lock xx(mutex);
    if(!timerCallback->onList) return;
    TimerCallbackPtr nextNode(head);
    TimerCallbackPtr prevNode;
    while(true) {
        if(nextNode.get()==timerCallback.get()) {
            if(prevNode.get()!=NULL) {
                prevNode->next = timerCallback->next;
            } else {
                head = timerCallback->next;
            }
            timerCallback->next.reset();
            timerCallback->onList = false;
            return;
        }
        prevNode = nextNode;
        nextNode = nextNode->next;
    }
    throw std::logic_error(string(""));
}
示例#30
0
bool SpatialDimension::query(const Query& query, const Response& range, Response& response) const {
	if (!query.evalAnyRegion(_key) && !query.evalAnyTile(_key)) return false;

	auto node_it = _nodes.begin();
	for (auto range_it = range.begin(); range_it != range.end(); ++range_it) {

		nextNode(*range_it, node_it);

		while ((**range_it).endAfter((*node_it)->front())) {

			if (query.type == Query::TILE) {
				(*node_it)->queryTile(this, query, response, 0);
			} else {
				(*node_it)->queryRegion(this, query, response, 0);
			}
						
			if (++node_it == _nodes.end()) return true;
		}
	}

	return true;
}