|
Boost : |
From: Phil Endecott (spam_from_boost_dev_at_[hidden])
Date: 2007-04-13 12:46:49
Neal Becker wrote:
> I have been using boost::range heavily, and find it useful for generic
> interfaces. I think it is also useful to have a multi-dimensional
> extension to range. In particular, a 2-d extension would help in creating
> algorithms that can accept a variety of 2-d structures.
>
> For example, range has size, begin, end.
>
> range2d would have size1, size2, begin1, begin2.
>
> Other useful members might include row, col.
Yes, I have been thinking along the same lines. In fact I thought
about this earlier today after Janek Kozicki posted asking what the
focus of the proposed SoC geometry library is. I would very much like
to see some 2D containers, e.g. set<point2d> and map<point2d,T>,
implemented using R-trees or similar. For Boost, I presume that any
such code will be expected to be "standard library like", and I was
wondering how similar a set<point2d> can be to a set<int>. In
particular, when I want to iterate over all the points within a
rectangle, I would love to be able to write:
for(set<point2d>::const_iterator i = points.lower_bound(point2d(x0,y0));
i != points.upper_bound(point2d(x1,y1)); ++i)
Unfortunately it can't be quite that similar to the 1D case. Currently
I have some very crude code where I define what I call a "window" into
the set of points:
window w(points,point(x0,y0),point(x1,y1));
for(set<point2d>::const_iterator i = w.begin();
i != w.end(); ++i)
Of course, having seen Neal's message, I realise that my "window" is
just a 2D range.
Clearly, it would be a good plan to get basics like this (and things
like a point type) thought about before Huseyin Akcan starts on his SoC
work. (Huseyin, I hope you're reading this! Do please let us know
what exactly you intend to do.)
I have been considering writing something to implement set<point> using
space filling curves. I haven't thought about it much yet and would
value any suggestions. My hope is that using this technique I can
adapt the standard associative containers to work with 2D points, and
thereby avoid having to implement any tree stuff.
In my case I'm dealing with latitude/longitude values and I think that
the first thing I need is a fixed-point type, so that I can do the bit
interleaving that the space filling curves need. That could make a
simple self-contained Boost library - is anyone interested?
Phil.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk