Revision history for TutLinkedLists


Revision [22193]

Last edited on 2018-02-08 21:20:45 by sancho3
Additions:
//Last edited by ""sancho3"" on February 8, 2018//


Revision [20697]

Edited on 2016-02-10 16:15:19 by DkLwikki [Update link format]
Additions:
If ((node->pData <> 0) And (bDelete <> 0)) Then DeAllocate node->pData
Deletions:
pTemp->pPrev = list->pNext
pTemp = pTemp->pNext
pPrev->pNext = pNext
pNext->pPrev = pPrev
If ((node->pData <> 0) And (bDelete <> 0)) Then DeAllocate node->pData
node = ListRemove(node)


Revision [15220]

Edited on 2011-09-25 05:34:05 by DkLwikki [Updated to current FB]
Additions:
declare sub ListRemoveAll(list as listnode ptr, bDelete as integer = 0)
function ListCreate() as listnode ptr
function ListGetFirst(list as listnode ptr) as listnode ptr
function ListGetLast(list as listnode ptr) as listnode ptr
function ListGetNext(list as listnode ptr) as listnode ptr
function ListGetPrev(list as listnode ptr) as listnode ptr
function ListRemove(list as listnode ptr, bDelete as integer = 0) as listnode ptr
sub ListRemoveAll(list as listnode ptr, bDelete as integer = 0)
if (list = 0) then return
end sub
Type listnode
As Any Ptr pData
As listnode Ptr pNext
As listnode Ptr pPrev
End Type
Declare Function ListCreate() As listnode Ptr
Declare Function ListAdd(list As listnode Ptr, item As Any Ptr) As Any Ptr
Declare Function ListAddHead(list As listnode Ptr, item As Any Ptr) As Any Ptr
Declare Function ListGetFirst(list As listnode Ptr) As listnode Ptr
Declare Function ListGetLast(list As listnode Ptr) As listnode Ptr
Declare Function ListGetNext(list As listnode Ptr) As listnode Ptr
Declare Function ListGetPrev(list As listnode Ptr) As listnode Ptr
Declare Function ListGetData(list As listnode Ptr) As Any Ptr
Declare Function ListRemove(list As listnode Ptr, bDelete As Integer = 0) As listnode Ptr
Declare Sub ListRemoveAll(list As listnode Ptr, bDelete As Integer = 0)
Dim As listnode Ptr list, node
Dim As Integer Ptr item
item = ListAdd(list, Callocate(Len(Integer)))
item = ListAdd(list, Callocate(Len(Integer)))
While node <> 0
Print "found item"
Print *item
Wend
While InKey$ = "" : Wend
Function ListCreate() As listnode Ptr
Dim As listnode Ptr pTemp
pTemp = Callocate(Len(listnode))
Return pTemp
End Function
Function ListAdd(list As listnode Ptr, item As Any Ptr) As Any Ptr
Dim As listnode Ptr pTemp
If (list = 0) Then Return item
pTemp->pNext = Callocate(Len(listnode))
Return item
End Function
Function ListAddHead(list As listnode Ptr, item As Any Ptr) As Any Ptr
Dim As listnode Ptr pTemp
If (list = 0) Then Return item
list->pNext = Callocate(Len(listnode))
If (pTemp <> 0) Then
pTemp->pPrev = list->pNext
End If
Return item
End Function
Function ListGetFirst(list As listnode Ptr) As listnode Ptr
If (list = 0) Then Return 0
Return list->pNext
End Function
Function ListGetLast(list As listnode Ptr) As listnode Ptr
Dim As listnode Ptr pTemp
If (list = 0) Then Return 0
While (pTemp->pNext <> 0)
pTemp = pTemp->pNext
Wend
Return pTemp
End Function
Function ListGetNext(list As listnode Ptr) As listnode Ptr
If (list = 0) Then Return 0
Return list->pNext
End Function
Function ListGetPrev(list As listnode Ptr) As listnode Ptr
If (list = 0) Then Return 0
If (list->pPrev = 0) Then Return 0
If (list->pPrev->pPrev = 0) Then Return 0
Return list->pPrev
End Function
Function ListGetData(list As listnode Ptr) As Any Ptr
If (list = 0) Then Return 0
Return list->pData
End Function
Function ListRemove(list As listnode Ptr, bDelete As Integer = 0) As listnode Ptr
Dim As listnode Ptr pPrev
Dim As listnode Ptr pNext
If (list = 0) Then Return 0
If ((list->pData <> 0) And (bDelete <> 0)) Then DeAllocate list->pData
DeAllocate list
If (pPrev <> 0) Then
pPrev->pNext = pNext
End If
If (pNext <> 0) Then
pNext->pPrev = pPrev
End If
Return pNext
End Function
Sub ListRemoveAll(list As listnode Ptr, bDelete As Integer = 0)
Dim As listnode Ptr node
If (list = 0) Then Return
While (node <> 0)
If ((node->pData <> 0) And (bDelete <> 0)) Then DeAllocate node->pData
node = ListRemove(node)
Wend
End Sub
Deletions:
declare function ListRemoveAll(list as listnode ptr, bDelete as integer = 0)
function ListCreate() as any ptr
function ListGetFirst(list as listnode ptr) as any ptr
function ListGetLast(list as listnode ptr) as any ptr
function ListGetNext(list as listnode ptr) as any ptr
function ListGetPrev(list as listnode ptr) as any ptr
function ListRemove(list as listnode ptr, bDelete as integer = 0) as any ptr
function ListRemoveAll(list as listnode ptr, bDelete as integer = 0)
return
declare function ListRemoveAll(list as listnode ptr, bDelete as integer = 0)
dim as listnode ptr list, node
dim as integer ptr item
item = ListAdd(list, callocate(len(integer)))
item = ListAdd(list, callocate(len(integer)))
while node <> 0
print "found item"
print *item
wend
while inkey$ = "" : wend
function ListCreate() as any ptr
function ListGetFirst(list as listnode ptr) as any ptr
function ListGetLast(list as listnode ptr) as any ptr
function ListGetNext(list as listnode ptr) as any ptr
function ListGetPrev(list as listnode ptr) as any ptr
function ListRemove(list as listnode ptr, bDelete as integer = 0) as any ptr
function ListRemoveAll(list as listnode ptr, bDelete as integer = 0)
return


Revision [14477]

Edited on 2009-08-29 21:57:59 by CountingPine [Remove CamelCase links in "New to FreeBASIC"]
Additions:
As a side note, if whoever has access to these scripts would like to update it so it contains the keywords new to ""FreeBASIC"" (such as ptr), feel free to :) Also, LIST doesn't appear to be an FB keyword (correct me if I'm wrong).
Deletions:
As a side note, if whoever has access to these scripts would like to update it so it contains the keywords new to FreeBASIC (such as ptr), feel free to :) Also, LIST doesn't appear to be an FB keyword (correct me if I'm wrong).


Revision [11864]

The oldest known version of this page was created on 2007-11-30 01:03:23 by ElSairon [Remove CamelCase links in "New to FreeBASIC"]
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki



sf.net phatcode