[Dune] A question about the relationship between iterators and indices in dune-grid

Jö Fahlke jorrit at jorrit.de
Wed Sep 23 13:08:45 CEST 2009


Am Wed, 23. Sep 2009, 11:06:13 +0200 schrieb Oliver Sander:
> > B) If the answer in A) turns at to be negative, i.e. that there is no 
> > such obvious relationship between indices and iterators in the 
> > dune-grid: how do you relate a given index to the corresponding 
> > entity, or in other words, if you know the index of an entity, how do 
> > you obtain a pointer to this particular entity?
> There is not constant-time way to do so.  The only way is to iterate 
> through all entities and stop when
> you have found the one with the correct index.  Or, if you have lots of 
> memory, you could store an
> array of EntityPointers with an entry for each entity.  But both are 
> really only theoretical options.

I gather that your algorithm works by iterating over the indices, and then
tries to find the corresponding entity.  Usually such an algorithm can be
rewritten to iterate over the entities and find the corresponding index for
each entity instead.

Bye,
Jö.

-- 
F: Was ist der Sinn des Menschen?
A: Die Menschheit voranzubringen.
F: Aber was ist der Sinn der Menschheit?
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 827 bytes
Desc: Digital signature
URL: <https://lists.dune-project.org/pipermail/dune/attachments/20090923/044c0aea/attachment.sig>


More information about the Dune mailing list