Templates -- Meow  1.1.2
不能,也不應該先編譯成obj-file的templates
meow::KD_Tree< Vector, Scalar > Class Template Reference

k-dimension tree More...

#include "KD_Tree.h"

Public Types

typedef std::vector< VectorVectors
 Custom Type: Vectors is std::vector<Vector> More...
 

Public Member Functions

 KD_Tree ()
 constructor, with dimension = 1 More...
 
 KD_Tree (size_t dimension)
 constructor, given dimension More...
 
 ~KD_Tree ()
 destructor More...
 
void insert (Vector const &v)
 將給定的Vector加到set中 More...
 
bool erase (Vector const &v)
 將給定的Vector從set移除 More...
 
void build ()
 檢查至今是否有 insert/erase 被呼叫來決定是否 rebuild() More...
 
void forceBuild ()
 重新建樹 More...
 
Vectors query (Vector const &v, size_t nearestNumber, bool compareWholeVector) const
 查找 More...
 
void clear ()
 清空所有資料 More...
 
void reset (size_t dimension)
 清空所有資料並重新給定維度 More...
 

Detailed Description

template<class Vector, class Scalar>
class meow::KD_Tree< Vector, Scalar >

k-dimension tree

全名k-dimension tree, 用來維護由N個K維度向量所成的集合, 並可於該set中查找 前i個離給定向量最接近的向量

Template Class Operators Request

const?TypenameOperator Parameters Return Type Description
const Vector operator[] (size_t n) Scalar 取得第 n 維度量
const Vector operator< (Vector v) bool 權重比較
const Scalar operator* (Scalar s) Scalar 相乘
const Scalar operator+ (Scalar s) Scalar 相加
const Scalar operator- (Scalar s) Scalar 相差
const Scalar operator< (Scalar s) bool 大小比較
Note
: 此資料結構只有在 N >> 2 K 時才比較有優勢, 當 K 逐漸變大時, 所花時間會跟暴搜沒兩樣
Author
cat_leopard

Member Typedef Documentation

template<class Vector , class Scalar >
typedef std::vector<Vector> meow::KD_Tree< Vector, Scalar >::Vectors

Custom Type: Vectors is std::vector<Vector>

Constructor & Destructor Documentation

template<class Vector , class Scalar >
meow::KD_Tree< Vector, Scalar >::KD_Tree ( )
inline

constructor, with dimension = 1

template<class Vector , class Scalar >
meow::KD_Tree< Vector, Scalar >::KD_Tree ( size_t  dimension)
inline

constructor, given dimension

template<class Vector , class Scalar >
meow::KD_Tree< Vector, Scalar >::~KD_Tree ( )
inline

destructor

Member Function Documentation

template<class Vector , class Scalar >
void meow::KD_Tree< Vector, Scalar >::build ( )
inline

檢查至今是否有 insert/erase 被呼叫來決定是否 rebuild()

template<class Vector , class Scalar >
void meow::KD_Tree< Vector, Scalar >::clear ( )
inline

清空所有資料

template<class Vector , class Scalar >
bool meow::KD_Tree< Vector, Scalar >::erase ( Vector const &  v)
inline

將給定的Vector從set移除

template<class Vector , class Scalar >
void meow::KD_Tree< Vector, Scalar >::forceBuild ( )
inline

重新建樹

template<class Vector , class Scalar >
void meow::KD_Tree< Vector, Scalar >::insert ( Vector const &  v)
inline

將給定的Vector加到set中

template<class Vector , class Scalar >
Vectors meow::KD_Tree< Vector, Scalar >::query ( Vector const &  v,
size_t  nearestNumber,
bool  compareWholeVector 
) const
inline

查找

於set中找尋距離指定向量前 i 近的向量, 並依照由近而遠的順序排序. 如果有兩個向量v1,v2 距離一樣, 且 cmptrue , 則直接依照 v1<v2 來決定誰在前面. 最後回傳一陣列包含所有解.

template<class Vector , class Scalar >
void meow::KD_Tree< Vector, Scalar >::reset ( size_t  dimension)
inline

清空所有資料並重新給定維度


The documentation for this class was generated from the following file: