NO

Author Topic: Bug in double_linked_list  (Read 3819 times)

Tino

  • Guest
Bug in double_linked_list
« on: July 25, 2007, 09:54:58 PM »
Hello,

i tried to create a double_linked_list,
but somehow it doesn´t work as expected.

I wrote 2 routines,
one to show all list-members from the beginning
and one show then from end.

But the routine that should show all items beginning by the end of the list
only shows some members
and i can´t get the point where the app drops the rest..

Project attached.

Thanks,
Tino

Offline frankie

  • Global Moderator
  • Member
  • *****
  • Posts: 2096
Re: Bug in double_linked_list
« Reply #1 on: July 27, 2007, 03:23:22 PM »
Ok I'm posting the corrections, I can't easily follow your code also because my german is at level 0.
Anyway I introduced a lot of semplification, I would invite you to try to code in a more plain way, you put a lot of code where few lines can do the job.
As some games say "improve yourself" you're at good point  ;).
It is better to be hated for what you are than to be loved for what you are not. - Andre Gide

Tino

  • Guest
Re: Bug in double_linked_list
« Reply #2 on: July 27, 2007, 07:28:45 PM »
Hello frankie,


First a big -Thank You-,
i tried a tutorial, changed some parameters
and ended in total confusion..

The "Begining"/"Ending" stuff was a test to see
if the pointers work as imagined
and should lead to a delete routine ("loeschen" = "delete"),
which after your contribution seemed (very) easier to be build.

Here´s what i made out of it,
hope there are no more bugs ..



ps:

Now that you brought the term "insert in the middle",
i´m thinking how that could be realised.. ?

There are 2 interesting possibilities:
1st - Insert Item by index,
2nd - Insert Item before/after Item..

When thinking about the indexing,
i wondered how that should be done..
..counting via global variable
..a loop iterating each time through the list
..or even using an array ??

Do you know if there´s a standard / better solution ?


pss:

Please let me know what you mean by "plain" Style,
the basic framework of this sample is out of a tutorial,
i just changed the pointer-handling
because the original based all functions on a pointer which used to be the actual Item
really confusing and only working linear..
(no chance to add an item, delete, add again..)


Thanks,

Tino


Offline frankie

  • Global Moderator
  • Member
  • *****
  • Posts: 2096
Re: Bug in double_linked_list
« Reply #3 on: July 30, 2007, 06:15:24 PM »
Tino I posted a working double linked lists handling library that emulates OOP programming with many of the features that you required in the 'Tips & Tricks' thread.
I hope this would satisfy your needs.
This is the link http://www.smorgasbordet.com/forum/index.php?topic=2237.0
It is better to be hated for what you are than to be loved for what you are not. - Andre Gide

Tino

  • Guest
Re: Bug in double_linked_list
« Reply #4 on: July 30, 2007, 11:21:51 PM »
Hello Frankie,

Thanks - i posted answer in yout thread.

Tino