Re: Storing a tree in a std::list<>
From: Dave (better_cs_now_at_yahoo.com)
Date: 06/06/04
- Next message: Carl Ribbegaardh: "Re: Why code completion and early error checking are needed"
- Previous message: Asfand Yar Qazi: "const pointer / reference nonsense (to me, anyway :-)"
- In reply to: Alan Johnson: "Re: Storing a tree in a std::list<>"
- Next in thread: Jeff Schwab: "Re: Storing a tree in a std::list<>"
- Reply: Jeff Schwab: "Re: Storing a tree in a std::list<>"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sat, 5 Jun 2004 18:29:07 -0700
"Alan Johnson" <alanwj@mailandnews.com> wrote in message
news:40c267a1$1@news.ua.edu...
> Dave wrote:
> > Hello all,
> >
> > After perusing the Standard, I believe it is true to say that once you
> > insert an element into a std::list<>, its location in memory never
changes.
> > This makes a std::list<> ideal for storing vertices of an arbitrary
n-ary
> > tree where a vertex contain pointers to its parent / children. These
parent
> > / child vertices need to stay put if we've got pointers to them
somewhere!
> >
> > Am I correct in my assertion?
> >
> > Thanks,
> > Dave
> >
> >
>
> While that probably is true for almost any implementation, I don't think
> that the standard actually requires it. What it does require is that
> adding/removing elements (as well as most other operations) do not
> invalidate any iterators to elements of the list.
>
> Alan
Hmmm, references too. But yes, technically not pointers. I wonder if one
can assume that iterators and references not being invalidated implies that
pointers are not invalidated...
- Next message: Carl Ribbegaardh: "Re: Why code completion and early error checking are needed"
- Previous message: Asfand Yar Qazi: "const pointer / reference nonsense (to me, anyway :-)"
- In reply to: Alan Johnson: "Re: Storing a tree in a std::list<>"
- Next in thread: Jeff Schwab: "Re: Storing a tree in a std::list<>"
- Reply: Jeff Schwab: "Re: Storing a tree in a std::list<>"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|