[DGD] mapping question
Erwin Harte
harte at xs4all.nl
Wed Oct 10 17:44:38 CEST 2001
On Wed, Oct 10, 2001 at 05:31:36PM +0200, pete at ana.sk wrote:
>
> > Put the data into an array instead. The whole point of a mapping
> > is that, unlike an array, the indices are not sequential. If you
> > want sequential access, a mapping is the Wrong Thing. That's what
> > arrays are good at.
>
> Yes, its good point, but sequential access is only one small part of
> it, i need mapping for map indices access primarily. Just need to
> access all values and change some of them too regardless of index.
There is no perfect solution.
Nothing stops you from doing this:
...
for (i = 0; i < sz; i++) {
map[ind[i]] = <expression>;
}
What is the problem there? Using an integer index as 'alias' for
map[i] would cause problems anyway, imagine for instance what would
happen if the mapping would be changed during the for() loop, an item
added, one removed, etc. This way actually works safely.
Bye,
Erwin.
--
Erwin Harte <harte at xs4all.nl>
_________________________________________________________________
List config page: http://list.imaginary.com/mailman/listinfo/dgd
More information about the DGD
mailing list