[Rd] Pointers to external objects

Nicholas Lewin-Koh kohnicho@comp.nus.edu.sg
Fri, 6 Apr 2001 16:13:57 +0800 (GMT-8)

I am starting to work on some data structures (quad trees, bounding box
trees etc.) I would like to build these structures in C, and essentially
have a new primative data type accessible that is persistant through an R
session and can be written and retrived from .RData .

I think this is possible from my reading of the documentation, but I am
not exactly sure how to do it. In the R lang manual in section 2 objects
there is a mention of typeof returning externalptr I think this is what i
want. Let me try to be a bit more specific because i am getting confused

> kdtree<-build.tree(x,y,...) # two vectors of x and y coordinates 
                              # kdtree is a list of class tree and
                              # contains a pointer to the actual tree
                              # stucture
> objects.in.range(kdtree,xmin,xmax,ymin,ymax) # returns a list of 
                                               # external pointers to the
                                               # data with x,y in the
                                               # given range 
> q() # quit the R session, but if the user saves the session then kdtree
      # is saved and can be recovered when the user restarts R

I know I could do this using lists, but I am trying to keep the memory
overhead down.


                  N             Nicholas Lewin-Koh
                 / \            Dept of Statistics
           N----C   C==O        Program in Ecology and Evolutionary Biology
          ||   ||   |           Iowa State University
          ||   ||   |           Ames, IA 50011
          CH    C   N--CH3      http://www.public.iastate.edu/~nlewin
            \  / \ /            nlewin@iastate.edu
             N    C
             |   ||             Currently
            CH3   O             Graphics Lab
                                School of Computing
                                National University of Singapore
     The Real Part of Coffee    kohnicho@comp.nus.edu.sg

r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch