|
Boost : |
From: Thomas Becker (tmbecker1_at_[hidden])
Date: 2003-03-24 02:50:21
This email is to determine possible interest in a
submission to boost: the combining iterator.
Short Description
=================
The combining iterator is another iterator adaptor. It
holds a boost::tuple of iterators. Moving the
combining iterator in any way causes all member
iterators of the tuple to move in parallel. Upon
dereferencing the combining iterator, the dereferenced
values of the member iterators are supplied as
arguments to a client-supplied n-ary functional, and
the return value of the functional is returned. The
combining iterator is thus a "higher-dimensional
transforming iterator."
Background and Current Use
==========================
The combining iterator grew out of a large software
project where a math engine calculates sequences of
numbers that are then used by a charting package as
data input. The math eninge exposes its sequences as
pairs of iterators. It happens frequently that two
sequences of doubles have been calculated for some
purpose, and then the sequence consisting of the
quotients of the respective values is needed. Storing
the quotients in a third sequence would clearly be a
colossally dumb decision in terms of time-space
tradeoff. Instead, the math engine exposes a combining
iterator that parallel-iterates over the two given
sequences and, upon dereferencing, returns the
quotient of the two values at its current position.
Many more situations exist in this software where a
simple arithmetic expression is calculated on the fly
from two or more sequences of numbers.
Anectdotal Background
=====================
We started working on the software mentioned above in
1997, and we have been using the STL and generic
programming paradigms from Day 1. We have used "smart
iterators" as early as 1998. Back then, the idea
seemed so new to me that I wrote an article about it
in CUJ (CUJ September 1998). Two years later, we had
accumulated so many "smart," or "custom" iterators
that my friend and colleague Chris Baus and I wrote
antother article about it for the 2000 C++ Template
Workshop (http://oonumerics.org/tmpw00). Needless to
say, from today's point of view, our smart iterators
were all spit'n duct tape. It was of course the
boost::iterator_adaptor (which by the way was first
presented at the 2001 C++ Template Workshop,
http://oonumerics.org/tmpw00) that provided the proper
framework for doing this. I recently noticed that the
ready-to-use boost now provide almost everything that
we use, with the exception of the combining iterator.
But this is a very important one for us, hence the
proposed submission.
Please comment.
Thomas Becker
Zephyr Associates, Inc.
Zephyr Cove, NV
__________________________________________________
Do you Yahoo!?
Yahoo! Platinum - Watch CBS' NCAA March Madness, live on your desktop!
http://platinum.yahoo.com
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk