queso-0.53.0
Classes | Public Member Functions | Private Attributes | List of all members
ANNmin_k Class Reference

#include <pr_queue_k.h>

Collaboration diagram for ANNmin_k:
Collaboration graph
[legend]

Classes

struct  mk_node
 

Public Member Functions

 ANNmin_k (int max)
 
 ~ANNmin_k ()
 
PQKkey ANNmin_key ()
 
PQKkey max_key ()
 
PQKkey ith_smallest_key (int i)
 
PQKinfo ith_smallest_info (int i)
 
void insert (PQKkey kv, PQKinfo inf)
 

Private Attributes

int k
 
int n
 
mk_nodemk
 

Detailed Description

Definition at line 66 of file pr_queue_k.h.

Constructor & Destructor Documentation

ANNmin_k::ANNmin_k ( int  max)
inline

Definition at line 77 of file pr_queue_k.h.

References k, mk, and n.

78  {
79  n = 0; // initially no items
80  k = max; // maximum number of items
81  mk = new mk_node[max+1]; // sorted array of keys
82  }
mk_node * mk
Definition: pr_queue_k.h:74
ANNmin_k::~ANNmin_k ( )
inline

Definition at line 84 of file pr_queue_k.h.

References mk.

85  { delete [] mk; }
mk_node * mk
Definition: pr_queue_k.h:74

Member Function Documentation

PQKkey ANNmin_k::ANNmin_key ( )
inline

Definition at line 87 of file pr_queue_k.h.

References mk, n, and PQ_NULL_KEY.

88  { return (n > 0 ? mk[0].key : PQ_NULL_KEY); }
const PQKkey PQ_NULL_KEY
Definition: pr_queue_k.h:46
mk_node * mk
Definition: pr_queue_k.h:74
void ANNmin_k::insert ( PQKkey  kv,
PQKinfo  inf 
)
inline

Definition at line 99 of file pr_queue_k.h.

References ANN_FLOP, ANNmin_k::mk_node::info, k, ANNmin_k::mk_node::key, mk, and n.

Referenced by ANNkd_leaf::ann_FR_search(), ANNkd_leaf::ann_pri_search(), ANNkd_leaf::ann_search(), ANNbruteForce::annkFRSearch(), and ANNbruteForce::annkSearch().

102  {
103  register int i;
104  // slide larger values up
105  for (i = n; i > 0; i--) {
106  if (mk[i-1].key > kv)
107  mk[i] = mk[i-1];
108  else
109  break;
110  }
111  mk[i].key = kv; // store element here
112  mk[i].info = inf;
113  if (n < k) n++; // increment number of items
114  ANN_FLOP(k-i+1) // increment floating ops
115  }
mk_node * mk
Definition: pr_queue_k.h:74
#define ANN_FLOP(n)
Definition: ANNperf.h:131
PQKinfo ANNmin_k::ith_smallest_info ( int  i)
inline

Definition at line 96 of file pr_queue_k.h.

References mk, n, and PQ_NULL_INFO.

Referenced by ANNbruteForce::annkFRSearch(), ANNkd_tree::annkFRSearch(), ANNkd_tree::annkPriSearch(), ANNbruteForce::annkSearch(), and ANNkd_tree::annkSearch().

97  { return (i < n ? mk[i].info : PQ_NULL_INFO); }
const PQKinfo PQ_NULL_INFO
Definition: pr_queue_k.h:47
mk_node * mk
Definition: pr_queue_k.h:74
PQKkey ANNmin_k::ith_smallest_key ( int  i)
inline

Definition at line 93 of file pr_queue_k.h.

References mk, n, and PQ_NULL_KEY.

Referenced by ANNbruteForce::annkFRSearch(), ANNkd_tree::annkFRSearch(), ANNkd_tree::annkPriSearch(), ANNbruteForce::annkSearch(), and ANNkd_tree::annkSearch().

94  { return (i < n ? mk[i].key : PQ_NULL_KEY); }
const PQKkey PQ_NULL_KEY
Definition: pr_queue_k.h:46
mk_node * mk
Definition: pr_queue_k.h:74
PQKkey ANNmin_k::max_key ( )
inline

Definition at line 90 of file pr_queue_k.h.

References k, mk, n, and PQ_NULL_KEY.

Referenced by ANNkd_leaf::ann_pri_search(), ANNkd_leaf::ann_search(), and ANNkd_tree::annkPriSearch().

91  { return (n == k ? mk[k-1].key : PQ_NULL_KEY); }
const PQKkey PQ_NULL_KEY
Definition: pr_queue_k.h:46
mk_node * mk
Definition: pr_queue_k.h:74

Member Data Documentation

int ANNmin_k::k
private

Definition at line 72 of file pr_queue_k.h.

Referenced by ANNmin_k(), insert(), and max_key().

mk_node* ANNmin_k::mk
private
int ANNmin_k::n
private

Definition at line 73 of file pr_queue_k.h.

Referenced by ANNmin_k(), ANNmin_key(), insert(), ith_smallest_info(), ith_smallest_key(), and max_key().


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

Generated on Thu Jun 11 2015 13:52:33 for queso-0.53.0 by  doxygen 1.8.5