Mercurial > hg > audiodb
annotate accumulator_test.cpp @ 420:580f696c817c api-inversion
Split up accumulator.h into multiple files
One benefit is the sanity-preserving side-effect of only one class per
file; the main reason, though, is so that we can include accumulator.h
(the abstract base class) in more than one project file.
author | mas01cr |
---|---|
date | Wed, 24 Dec 2008 10:54:55 +0000 |
parents | 6e6f4c1cc14d |
children | 166312a124bc |
rev | line source |
---|---|
mas01cr@420 | 1 #include "accumulators.h" |
mas01cr@416 | 2 |
mas01cr@416 | 3 static NearestAccumulator<adb_result_dist_lt> *foo = new NearestAccumulator<adb_result_dist_lt>(); |
mas01cr@416 | 4 |
mas01cr@416 | 5 int main() { |
mas01cr@416 | 6 adb_result_t r; |
mas01cr@416 | 7 r.key = "hello"; |
mas01cr@416 | 8 r.ipos = 0; |
mas01cr@416 | 9 r.qpos = 0; |
mas01cr@416 | 10 r.dist = 3; |
mas01cr@416 | 11 foo->add_point(&r); |
mas01cr@416 | 12 r.ipos = 1; |
mas01cr@416 | 13 r.dist = 2; |
mas01cr@416 | 14 foo->add_point(&r); |
mas01cr@416 | 15 r.qpos = 1; |
mas01cr@416 | 16 foo->add_point(&r); |
mas01cr@416 | 17 |
mas01cr@416 | 18 adb_query_results_t *rs; |
mas01cr@416 | 19 rs = foo->get_points(); |
mas01cr@416 | 20 for (unsigned int k = 0; k < rs->nresults; k++) { |
mas01cr@416 | 21 r = rs->results[k]; |
mas01cr@416 | 22 printf("%s: %f %u %u\n", r.key, r.dist, r.qpos, r.ipos); |
mas01cr@416 | 23 } |
mas01cr@416 | 24 free(rs->results); |
mas01cr@416 | 25 free(rs); |
mas01cr@416 | 26 delete foo; |
mas01cr@416 | 27 return 1; |
mas01cr@416 | 28 } |