|
From: Per W. <pw...@ia...> - 2003-06-08 15:40:15
|
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. /Per W On Sun, 8 Jun 2003, Ioannis Vranos wrote: > > -----Original Message----- > > From: Per Westermark [mailto:pw...@ia...] > > Sent: Saturday, June 07, 2003 10:39 PM > > To: Ioannis Vranos > > Cc: 'Dev-Cpp-Users' > > Subject: RE: [Dev-C++] Single Linked List-IV > > > > > > The slstore() function DOES need it's last line, or else the > > list will not > > get a pointer to the last element. The pointer to the last > > element is used > > to allow insert of new elements last, without having to > > iterate throught > > the list. > > > Perhaps I am missing something but as I understand it the statement > > *last_arg=i; > > makes the preceding statement > > else > (*last_arg)->next=i; > > > redundant. > > > > > > > I know it's a bit extra noisy with dual indirection, but > > since the code > > is C and not C++, slstore() can't take references to pointers. > > > And? double pointers occupy space themselves too. > > > > > Ioannis Vranos > > * Programming pages: http://www.noicys.freeurl.com > * Alternative URL 1: http://run.to/noicys > * Alternative URL 2: http://www.noicys.cjb.net > > > > > ------------------------------------------------------- > 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 > |