Pointers admission for LinkedList functions

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

Post by Psychophanta »

Ohhhh, some people support Saddam, or Bush, Osama, etc. but nobody support my noble cause for request for "Pointers admission for LinkedList functions".

:cry: :cry: :cry: :cry: :cry: :cry: :cry:
PolyVector
Enthusiast
Enthusiast
Posts: 499
Joined: Wed Sep 17, 2003 9:17 pm
Location: Southern California
Contact:

Post by PolyVector »

Hey Psychophanta, I believe you are wrong about my example being redundant... The linked list internally uses the *Next and *Previous pointers...
If you'll notice, I never assign a value to *Next or *Previous... This is done internally by PureBasic...
It can be proven...

This Code Works:

Code: Select all

Structure LinkedString 
  *Next.LinkedString 
  *Previous.LinkedString 
  value.s 
EndStructure 

NewList Hello1.LinkedString() 
NewList Hello2.LinkedString() 
*ptr.LinkedString 
*ptr=AddElement(Hello1()) 
*ptr\value = "Hello1, Item One"
*ptr=AddElement(Hello1()) 
*ptr\value = "Hello1, Item Two"
*ptr=AddElement(Hello1()) 
*ptr\value = "Hello1, Item Three"

Procedure PrintListContents(*ptr.LinkedString) 
  Repeat 
    If *ptr 
      Debug *ptr\value 
    EndIf 
  *ptr=*ptr\Next
Until *ptr=0 
EndProcedure 

PrintListContents(FirstElement(Hello1()))
It does NOT work if you change the Structure to this:

Code: Select all

Structure LinkedString ;Notice that *Next and *Previous are reversed
  *Previous.LinkedString 
  *Next.LinkedString 
  value.s 
EndStructure 
If I were just creating duplicate pointers it wouldn't matter what order they occured in the structure...

anyways... Let's stop going on about this because we both agree that better internal support is needed...

On to the Osama jokes: :)
Last edited by PolyVector on Thu Oct 02, 2003 6:43 pm, edited 2 times in total.
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

Post by Psychophanta »

Hi PolyVector.

Thanx to Kale and you.
Perhaps Fred can make something with this matter. :?: :)


AL
Post Reply