list add last/list add first, what is the diff?

BlitzMax Forums/BlitzMax Beginners Area/list add last/list add first, what is the diff?

Zacho(Posted 2011) [#1]
I am looking into creating lists now and I see both of these functions, why are they different but there function is the same?


They both: "Description Add an object to a linked list. "

Can someone explain this to me? Thanks


Jesse(Posted 2011) [#2]
think of a list as a grocery list. you create your list as a grocery list. when you write your first item in the list if you use add last, it won't matter as it's the first item and the only item. so it won't matter if you use addlast or addfirst.
now the secont item if you use addfirst it will put it on top of the list before the first item that was put on the list. but if you use addlast it will be put after the first item in the list.
one good use for this is for display purpose. list can contain for example backgrounds bountains buildings and players. if you put the mountains in the top of the list then the buildings and finally the players. when you display it with eachin, the list will display first the mountains, on top(front) the building then the player which will look appropriately on the screen. this is just one reason there are other reasons but may take long to explain.

Last edited 2011

Last edited 2011


Zacho(Posted 2011) [#3]
Oh okay, I understand now. Yeah, this makes good sense. Thank you for your analogy.

(I am very sorry how I acted before. I remember talking to you when I was going through some problems in my life in these forums and I want to apologize about how I acted.)


Jesse(Posted 2011) [#4]
I don't even remember Zacho so don't worry. I don't hold grudges either so don't bother. what ever it was it was forgotten so pretend it never happened. i'm sitting here by the tv waching the soccer Gold cup and enjoing it with a couple of beers and going through the threads during the commercials. :)