Blitz logo

Blitz Devel :

From: Jason Riedy (ejr_at_[hidden])
Date: 1998-07-30 21:05:46


Oh well. And Todd Veldhuizen writes:
 -
 - In the current design, an index set is contained in an STL
 - container [...]

 - A[I] = B;

Something like A[I.begin(), I.end()] = B would actually be
more STL-ish. I'm assuming the operator[] has a definition
something like
  template <typename _Cont>
  out_type
  Array::operator[] (const _Cont& c)
If you were to change it to something like
  template <typename _Iter>
  out_type
  Array::operator[] (const _Iter first, const _Iter last)
you could use the indirection with plain old pointers and
C-style arrays. You'd have to pull some traits-tricks
to keep the latter from being called when you do things
like A[1, 2], though.

Of course, I'm saying this without looking at the actual code. ;)
And you could support both by implementing the A[I] call as
A[I.begin(), I.end()].

The STL style gets cumbersome to write, but it does give some
extra flexibility. I find the ability to initialize from a plain
C array (or a block of memory I treat that way) terribly useful.
The block of memory could be wrapped in an object, but that isn't
really necessary when I'm just feeding data from a chunk of C into
an object. (I've forgotten if you already have a memory-wrapping
object in there.)

 - The indexSet(I,J) returns an "adaptor" which allows
 - iteration through the cartesian product of I X J.

This is nifty, and really handy. I'm working on some templates
for use in sparse matrix pattern analysis, and iterator adapters
are great things for that. Doing the indexSet in the STLish
[begin(), end()) way would be down-right ugly...

Query: What are your assumptions about the iterator types
involved? Do you use them as just forward iterators (non-input
for the indexSex), as bidirectional iterators, etc?

Jason
--------------------- blitz-dev list --------------------------------
* To subscribe/unsubscribe: mail to majordomo_at_[hidden], with
"subscribe blitz-dev" or "unsubscribe blitz-dev" in the body of the message
* Blitz++ web page: http://oonumerics.org/blitz/