> > TreeBin* treebin;
>
> > SGTreeBinList::iterator j;
>
> > bool found = false;
>
> >
>
> > for (j = randomForest.begin(); (j != randomForest.end()) && (!found);
>
> > j++) {
>
> > if (((*j)->texture == mat->get_tree_texture() ) &&
>
> > ((*j)->texture_varieties == mat->get_tree_varieties()) &&
>
> > ((*j)->range == mat->get_tree_range() ) &&
>
> > ((*j)->width == mat->get_tree_width() ) &&
>
> > ((*j)->height == mat->get_tree_height() ) ) {
>
> > treebin = *j;
>
> > found = true;
>
> > }
>
> > }
>
>
> It appears that SGTreeBinList is a list of pointers to some structure.
> If that is the case then you need to dereference two pointers to get
> stuff from the structure since the iterator, j, is a pointer. Thus you
> get *j->texture - *j dereferences j and -> dereferences the pointer
> pointed to by j. I don't think that you gain anything by writing this as
> (*j)->texture since this is basically the same thing as *j->texture. IMO
> *j->texture is easier to read.
But doesn't work. -> has higher precedence than *.
*j->texture is interpreted as *(j->texture) resulting in a compiler
error because j has no member named texture. You have to dereference j
before accessing the members, hence (*j)->texture.
To get rid of that (*j), you can assign a local variable:
for (j = randomForest.begin(); (j != randomForest.end()) && (!found); ++j) {
TreeBin * treeBin = *j;
if( treeBin->texture == mat->get_tree_texture() etc. etc.
You have to decide for yourself is this is an improvement ;-)
You can also make it worse: (*(*j)j).texture should also work ;-)
Torsten
Torsten
------------------------------------------------------------------------------
Got Input? Slashdot Needs You.
Take our quick survey online. Come on, we don't ask for help often.
Plus, you'll get a chance to win $100 to spend on ThinkGeek.
http://p.sf.net/sfu/slashdot-survey
_______________________________________________
Flightgear-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/flightgear-devel