!
! heaps
!
%endoflist

%owninteger i


%string(10)%array devices(contact:pass tran)
%string(6) %array wires(0:metal)
%record(SETS) sett
%record(SETS)%name settings== sett
!_________________________________________________

%recordformat ordered(%integer area,
                               dec index,
                               start,
                      %record(ordered)%name next)

%record(ORDERED)%array orderheap(1:800)
orderheap(i)_next== orderheap(i+1) %for i= 1,1,799 
orderheap(800)_next== nil
%record(ORDERED)%name top order heap== order heap(1)

!___________________________________________________________________________
%record(ORDERED)%map NEW ORDERED
%record(ORDERED)%name res== top order heap
%if res== nil %then printstring("
OUT OF ORDEREDS !") %andstop
top order heap== top order heap_next
res= 0
%result== res
%end
!___________________________________________________________________________
%routine DISPOSE ORDERED(%record(ORDERED)%name start)
%record(ORDERED)%name last
printstring("
dispose ordered !")
%while start## nil %cycle
  last== start
  start== start_next
  last= 0
  last_next== top order heap
  top order heap== last
%repeat
%end

!________________________________________________
%integer dec count= 1
%record(ARCC)%name %array dec arc(1:300,Xdir:Ydir)


%record(NODE) %array nodeheap(1:300) 
%record(ARCC) %array ARCC heap(1:1000) 
%record(NODE LIST)%array node list heap(1:100)

%record(NODE) %name  topnodeheap== node heap(1)
%record(ARCC) %name top ARCC heap== ARCC heap(1)
%record(NODE LIST)%name top node list heap== node list heap(1)


node heap(i)_next x==node heap(i+1) %for i=1,1,299
node heap(300)_next x == nil


ARCC heap(i)_another ARCC == ARCC heap(i+1) %for i=1,1,999
ARCC heap(1000)_another ARCC == nil



%record (ARCC) %map NEWARCC
 %record(ARCC) %name ptr
  ptr== top ARCC heap
  top ARCC heap== topARCC heap_another ARCC
  ptr= 0
  %result== ptr
%end

%routine DISPOSE ARCC(%record(ARCC) %name ptr)
 ptr= 0
 ptr_another ARCC== top ARCC heap
 top ARCC heap== ptr
%end

%record(NODE) %map NEWNODE
 %record(NODE) %name ptr
 ptr== top node heap
 top node heap== top node heap_next x
 ptr= 0
 %result== ptr
%end

%routine DISPOSE NODE(%record(NODE) %name ptr)
 ptr=0
 ptr_next x== top node heap
 top node heap== ptr
%end






node list heap(i)_next== node list heap(i+1) %for i=1,1,99
node list heap(100)_next== nil



%record(NODE LIST)%map NEW NODE LIST
%record(NODE LIST)%name res
  res== top node list heap
  top node list heap== res_next
  res= 0
%result== res
%end

%routine DISPOSE NODE LIST(%record(NODE LIST)%name ptr)
   ptr= 0
   ptr_next== top node list heap
   top node list heap== ptr
%end

!____________________________________________________________________



%record(NODE) no match,top


!______________________________________________________________________

%const %integer screen x= 690
%const %integer screen y= 450

! cell identifiers

%integer %array cell x(0:20)
%integer %array cell y(0:20)
%string(20) %array cell name(0:20)

i=0
cell name(i)="" %and i=i+1 %until i>20

cell x(0)= screen x
cell y(0)= screen y

%integer cell size x= 0,   cell size y= 0


%integer current rot= 0
%integer current cell= not set

%record(NODE LIST) start cell list= 0
%record(NODE LIST)%name cell list== start cell list
%record(NODE LIST)%name end cell list== cell list

%routine THE LONG AND THE SHORT
! corrects out of reach difficulties
devices(contact)="contact"
devices(pull down)="pull_down"
devices(pull up)="pull_up"
devices(pass tran)="pass_trans"
wires(0)= "delete"
wires(poly)="poly"
wires(diff)="diff"
wires(metal)="metal"
%end


THE LONG AND THE SHORT
%list
%endoffile
