本文整理汇总了C++中Searcher::locationToNode方法的典型用法代码示例。如果您正苦于以下问题:C++ Searcher::locationToNode方法的具体用法?C++ Searcher::locationToNode怎么用?C++ Searcher::locationToNode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Searcher
的用法示例。
在下文中一共展示了Searcher::locationToNode方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testLocationToNodeReturnsCorrectNode
void SearcherTest::testLocationToNodeReturnsCorrectNode(Searcher searcher) {
int* location = new int[2];
location[0] = 0; location[1] = 0; assert(searcher.locationToNode(location) == 0);
location[0] = 2; location[1] = 12; assert(searcher.locationToNode(location) == 38);
location[0] = 3; location[1] = 0; assert(searcher.locationToNode(location) == 39);
location[0] = 4; location[1] = 7; assert(searcher.locationToNode(location) == 59);
location[0] = 7; location[1] = 12; assert(searcher.locationToNode(location) == 103);
}
示例2: testInitializeSingleSourceSetsDistanceAndPathRight
void SearcherTest::testInitializeSingleSourceSetsDistanceAndPathRight(Searcher searcher) {
searcher.initializeSingleSource();
int* path = searcher.getPath();
int* distance = searcher.getDistance();
int inf = infinity;
for (int row = 0; row < 8; row++) {
for (int col = 0; col < 13; col++) {
int location[2] = {row, col};
int node = searcher.locationToNode(location);
assert(path[node] == -1);
if (row == startLocation[0] && col == startLocation[1]) assert(distance[node] == 0);
else assert(distance[node] == inf);
}
}
}