home *** CD-ROM | disk | FTP | other *** search
- 1 m=29:rem list for 197 entries
- 2 gosub 10
- 3 goto 300
- 10 rem - define hashfunction -
- 11 rem - and initialize table -
- 12 def fn modm(n)=n-int(n/m)*m
- 13 def fn h(k)=fn modm(fn modm(k)+i)
- 14 dim t(m): rem array
- 15 dim a$(m):rem dimensions
- 16 for j=0 to m:t(j)=-1:next:rem delete
- 17 return
- 30 rem ---- hash insert ----
- 40 i=0
- 50 j=fn h(k)
- 60 if t(j)<0 then t(j)=k:return
- 70 i=i+1:if i < m goto 50
- 80 print "?hash table overflow error":stop
- 90 j=-1:return
- 100 rem ---- hash search ----
- 110 i=0
- 120 j=fn h(k)
- 130 if t(j)=k then return
- 140 i=i+1
- 150 if (t(j)=-1) or (i=m) then j=-1:return
- 160 goto 120
- 170 rem ---- hash delete ----
- 180 gosub 110:if j=-1 then return
- 190 t(j)=-2:return
- 300 print "[147]1.new entry"
- 310 print "2.search"
- 320 print "3.delete"
- 330 get x$:if x$="" then goto 330
- 340 if x$="1" then gosub 1000
- 350 if x$="2" then gosub 2000
- 360 if x$="3" then gosub 3000
- 370 goto 300
- 1000 input "name";n$
- 1010 input "telephone number";k
- 1020 gosub 30
- 1030 if j=-1 then print "list full!"
- 1040 if j>=0 then print "list position:";j
- 1050 a$(j)=n$:poke198,0:wait198,1:return
- 2000 input "telephone number";k
- 2010 gosub 100
- 2020 if j=-1 then print"not found!":goto2050
- 2030 print "list position:";j
- 2040 print "name:";a$(j)
- 2050 poke198,0:wait198,1:return
- 3000 input "telephone number";k
- 3010 gosub 170:print"entry deleted"
- 3020 poke198,0:wait198,1:return
-