Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
|
|
@ -0,0 +1,91 @@
|
|||
CARD EndProg ;required for ALLOCATE.ACT
|
||||
|
||||
INCLUDE "D2:ALLOCATE.ACT" ;from the Action! Tool Kit. You must type 'SET EndProg=*' from the monitor after compiling, but before running this program!
|
||||
|
||||
DEFINE PTR="CARD"
|
||||
DEFINE NODE_SIZE="3"
|
||||
TYPE ListNode=[CHAR data PTR nxt]
|
||||
|
||||
ListNode POINTER listBegin
|
||||
|
||||
PROC AddBegin(CHAR v)
|
||||
ListNode POINTER n
|
||||
|
||||
n=Alloc(NODE_SIZE)
|
||||
n.data=v
|
||||
n.nxt=listBegin
|
||||
listBegin=n
|
||||
RETURN
|
||||
|
||||
PROC AddAfter(CHAR v ListNode POINTER node)
|
||||
ListNode POINTER n
|
||||
|
||||
IF node=0 THEN
|
||||
PrintE("The node is null!") Break()
|
||||
ELSE
|
||||
n=Alloc(NODE_SIZE)
|
||||
n.data=v
|
||||
n.nxt=node.nxt
|
||||
node.nxt=n
|
||||
FI
|
||||
RETURN
|
||||
|
||||
PROC Clear()
|
||||
ListNode POINTER n,next
|
||||
|
||||
n=listBegin
|
||||
WHILE n
|
||||
DO
|
||||
next=n.nxt
|
||||
Free(n,NODE_SIZE)
|
||||
n=next
|
||||
OD
|
||||
listBegin=0
|
||||
RETURN
|
||||
|
||||
PROC PrintList()
|
||||
ListNode POINTER n
|
||||
|
||||
n=listBegin
|
||||
Print("(")
|
||||
WHILE n
|
||||
DO
|
||||
Put(n.data)
|
||||
IF n.nxt THEN
|
||||
Print(", ")
|
||||
FI
|
||||
n=n.nxt
|
||||
OD
|
||||
PrintE(")")
|
||||
RETURN
|
||||
|
||||
PROC TestAddBegin(CHAR v)
|
||||
AddBegin(v)
|
||||
PrintF("Add '%C' at the begin:%E",v)
|
||||
PrintList()
|
||||
RETURN
|
||||
|
||||
PROC TestAddAfter(CHAR v ListNode POINTER node)
|
||||
AddAfter(v,node)
|
||||
PrintF("Add '%C' after '%C':%E",v,node.data)
|
||||
PrintList()
|
||||
RETURN
|
||||
|
||||
PROC TestClear()
|
||||
Clear()
|
||||
PrintE("Clear the list:")
|
||||
PrintList()
|
||||
RETURN
|
||||
|
||||
PROC Main()
|
||||
Put(125) PutE() ;clear screen
|
||||
|
||||
AllocInit(0)
|
||||
listBegin=0
|
||||
|
||||
PrintList()
|
||||
TestAddBegin('A)
|
||||
TestAddAfter('B,listBegin)
|
||||
TestAddAfter('C,listBegin)
|
||||
TestClear()
|
||||
RETURN
|
||||
Loading…
Add table
Add a link
Reference in a new issue