[Implemented] inkedList copy element ability!
Posted: Sat Dec 22, 2001 1:09 am
Restored from previous forum. Originally posted by Shagwana.
Right first off let me put some code up;
What I would like to see is the ability to do 'Buffer.ListInfo=Pep()' and 'Pep()=Buffer.ListInfo' in the above code. As it stands, when we need to duplicate the data held in a list, we have to iterate throught each field in the element and copy it over - not good for big structures .
http://www.sublimegames.com
Right first off let me put some code up;
Code: Select all
;A structure to hold info
Structure ListInfo
Name.s
EndStructure
;Fill the list
NewList Pep.ListInfo()
AddElement(Pep())
Pep()\Name$="1:Shagwana"
AddElement(Pep())
Pep()\Name$="2:Robins"
AddElement(Pep())
Pep()\Name$="3:Blu_Matt"
AddElement(Pep())
Pep()\Name$="4:Gfk"
AddElement(Pep())
Pep()\Name$="5:xMystik"
Procedure DisplayPep()
ResetList(Pep())
m$="List size "+Str(CountList(Pep()))+";"+Chr(10)+Chr(10)
While NextElement(Pep())
m$=m$+Pep()\Name$+Chr(10)
Wend
MessageRequester("Pep list:", m$, 0)
EndProcedure
Global Buffer.ListInfo ;used in copy
;Show the list
DisplayPep()
;Move the last element to the front of the list
LastElement(Pep())
;Buffer.ListInfo=Pep() ;WISHLIST
Buffer.ListInfo\Name$=Pep()\Name$
DeleteElement(Pep())
FirstElement(Pep())
InsertElement(Pep())
;Pep()=Buffer.ListInfo ;WISHLIST
Pep()\Name$=Buffer.ListInfo\Name$
;Reshow the list - last should be first!
DisplayPep()
End
http://www.sublimegames.com