?? examples.html
字號(hào):
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<head>
<title>Source Code Examples</title>
</head>
<body bgcolor=white>
<h1>Source Code Examples</h1>
<hr>
<p>
For complete examples, please refer to the source code of <a
href="commands.html">sample commands</a> contained in the directories
`<code>c++-samples</code>' and `<code>c-samples</code>'.
</p>
<ul>
<li><a href="#fetchNN">Running nearest neighbor search.</a></li>
<li><a href="#fetchInRect">Running range search.</a></li>
</ul>
<hr>
<a name="fetchNN"></a><h2>Running nearest neighbor search.</h2>
<p>
The following is an example of using the function
`<code>getNeighbors()</code>'.
</p>
<blockquote>
<table border=1 bgcolor=lightyellow cellpadding=10>
<tr><td>
<pre>
(C++)
HnSRTreeFile file;
HnPoint queryPoint;
int i, numNeighbors;
HnPointVector points;
HnDataItemVector dataItems;
. . .
/* open an index file and prepare `queryPoint' and `numNeighbors' */
. . .
file.getNeighbors(queryPoint, numNeighbors, &points, &dataItems);
for ( i=0; i<points.size(); i++ ) {
HnPoint point = points.elementAt(i);
HnDataItem dataItem = dataItems.elementAt(i);
. . .
/* work with `point' and `dataItem' */
. . .
}
/* close an index file */
(C )
HnSRTreeFileSt *file;
HnPointSt *queryPoint;
int i, numNeighbors;
HnPointVectorSt *points;
HnDataItemVectorSt *dataItems;
. . .
/* open an index file and prepare `queryPoint' and `numNeighbors' */
. . .
HnSRTreeFileSt_getNeighbors(file, queryPoint, numNeighbors,
&points, &dataItems);
for ( i=0; i<points->size; i++ ) {
HnPointSt *point = points->elements[i];
HnDataItemSt *dataItem = dataItems->elements[i];
. . .
/* work with `point' and `dataItem' */
. . .
}
HnPointVectorSt_freeElements(points);
HnPointVectorSt_free(points);
HnDataItemVectorSt_freeElements(dataItems);
HnDataItemVectorSt_free(dataItems);
/* close an index file and delete `queryPoint' */
</pre>
</td></tr>
</table>
See also
<a href="classes.html#HnPoint">HnPoint</a>,
<a href="classes.html#HnDataItem">HnDataItem</a>,
<a href="classes.html#HnPointVector">HnPointVector</a>,
<a href="classes.html#HnDataItemVector">HnDataItemVector</a>.
</blockquote>
<hr>
<a name="fetchInRect"></a><h2>Running range search.</h2>
<p>
The following is an example of using the function `<code>getFirst()</code>'
and `<code>getNext()</code>'.
</p>
<blockquote>
<table border=1 bgcolor=lightyellow cellpadding=10>
<tr><td>
<pre>
(C++)
HnSRTreeFile file;
HnRect queryRect;
HnPoint point;
HnDataItem dataItem;
. . .
/* open an index file and prepare `queryRect' */
. . .
file.getFirst(queryRect, &point, &dataItem);
while ( point != HnPoint::null ) {
. . .
/* work with `point' and `dataItem' */
. . .
file.getNext(&point, &dataItem);
}
/* close an index file */
(C )
HnSRTreeFileSt *file;
HnRectSt *queryRect;
HnPointSt *point;
HnDataItemSt *dataItem;
. . .
/* open an index file and prepare `queryRect' */
. . .
HnSRTreeFileSt_getFirstInRect(file, queryRect, &point, &dataItem);
while ( point != NULL ) {
. . .
/* work with `point' and `dataItem' */
. . .
HnPointSt_free(point);
HnDataItemSt_free(dataItem);
HnSRTreeFileSt_getNext(file, &point, &dataItem);
}
/* close an index file and delete `queryRect' */
</pre>
</td></tr>
</table>
See also
<a href="classes.html#HnRect">HnRect</a>,
<a href="classes.html#HnPoint">HnPoint</a>,
<a href="classes.html#HnDataItem">HnDataItem</a>.
</blockquote>
<hr>
[<a href="index.html">TOC</a>]
[<a href="library.html">Library</a>]
[<a href="classes.html">Classes</a>]
[<a href="commands.html">Commands</a>]
[<a href="examples.html">Examples</a>]
[<a href="references.html">References</a>]
<p>
<i>Any feedback is appreciated (corrections, suggestions, etc.).</i>
</p>
<address>
Norio KATAYAMA
<<a href="mailto:katayama@nii.ac.jp">katayama@nii.ac.jp</a>>
</address>
</body>
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -