|
From: Per W. <pw...@ia...> - 2003-06-09 04:52:12
|
A variation on the theme is to build the list as a ring. Then you
get:
getfirst() { return last ? last->next : NULL; }
getlast() { return last; }
getnext(ptr) { return ptr == last ? NULL : ptr->next; }
Quick insert both at head and tail, but list only needs one pointter.
/Per W
On Mon, 9 Jun 2003, Ioannis Vranos wrote:
> Ok, got it.
>
>
>
>
>
> Ioannis Vranos
>
> * Programming pages: http://www.noicys.freeurl.com
> * Alternative URL 1: http://run.to/noicys
> * Alternative URL 2: http://www.noicys.cjb.net
>
>
>
> > -----Original Message-----
> > From: Per Westermark [mailto:pw...@ia...]
> > Sent: Sunday, June 08, 2003 6:39 PM
> > To: Ioannis Vranos
> > Cc: Dev-C++ Mailing List
> > Subject: RE: [Dev-C++] Single Linked List-IV
> >
> >
> > If the list is non-empty, then *last is non-NULL. In that
> > case, the OLD
> > last entry should have it's next pointer pointing at the NEW
> > last entry.
> >
> > It doesn't matter if the list was empty or not. After an insert - the
> > insert is always at the end of the list - *last should be set
> > to point to
> > the NEW last entry. Without this last line, LAST would always
> > be NULL, and
> > you wouldn't get a linked list.
>
>
>
>
> -------------------------------------------------------
> This SF.net email is sponsored by: Etnus, makers of TotalView, The best
> thread debugger on the planet. Designed with thread debugging features
> you've never dreamed of, try TotalView 6 free at www.etnus.com.
> _______________________________________________
> Dev-cpp-users mailing list
> Dev...@li...
> TO UNSUBSCRIBE: http://www.noicys.cjb.net/devcpp/ub.htm
> https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
>
|