ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Tree-M/M.xs
(Generate patch)

Comparing Tree-M/M.xs (file contents):
Revision 1.1 by root, Sun May 6 00:45:51 2001 UTC vs.
Revision 1.3 by root, Sun May 6 03:30:17 2001 UTC

10typedef double *Key; 10typedef double *Key;
11 11
12static double * 12static double *
13sv2c(SV *sv, int ndims) 13sv2c(SV *sv, int ndims)
14{ 14{
15 if (!SvROK (sv) && SvTYPE (SvRV (sv)) != SVt_PVAV) 15 if (!SvROK (sv) || SvTYPE (SvRV (sv)) != SVt_PVAV)
16 croak ("Tree::M: key must be array references"); 16 croak ("Tree::M: key must be array reference");
17 17
18 AV *av = (AV *)SvRV (sv); 18 AV *av = (AV *)SvRV (sv);
19 19
20 if (av_len (av) != ndims -1) 20 if (av_len (av) != ndims -1)
21 croak ("Tree::M: illegal key, expected %d elements, found %d", 21 croak ("Tree::M: illegal key, expected %d elements, found %d",
41 return newRV_noinc ((SV *)av); 41 return newRV_noinc ((SV *)av);
42} 42}
43 43
44static AV *searchres; 44static AV *searchres;
45 45
46void add_result(double distance, int data, double *k, int ndims) 46void add_result(int data, double *k, int ndims)
47{ 47{
48 AV *r = newAV (); 48 AV *r = newAV ();
49 49
50 av_push (r, newSVnv (distance));
51 av_push (r, newSViv (data)); 50 av_push (r, newSViv (data));
52 av_push (r, c2sv (k, ndims)); 51 av_push (r, c2sv (k, ndims));
53 52
54 av_push (searchres, newRV_noinc ((SV *)r)); 53 av_push (searchres, newRV_noinc ((SV *)r));
55} 54}
56 55
57MODULE = Tree::M PACKAGE = Tree::M::MT 56MODULE = Tree::M PACKAGE = Tree::M
58 57
59PROTOTYPES: ENABLE 58PROTOTYPES: ENABLE
60 59
61PMT * 60PMT *
62new(class, ndims, min = 0.0, max = 255.0, steps = 65536.0) 61new(class, ndims, min = 0.0, max = 255.0, steps = 65536.0)
111 THIS->top(sv2c(k, THIS->ndims), n); 110 THIS->top(sv2c(k, THIS->ndims), n);
112 RETVAL = newRV_noinc ((SV *)searchres); 111 RETVAL = newRV_noinc ((SV *)searchres);
113 OUTPUT: 112 OUTPUT:
114 RETVAL 113 RETVAL
115 114
115int
116PMT::maxlevel()
117
116void 118void
117PMT::DESTROY() 119PMT::DESTROY()
118 120

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines