Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
|
|
@ -0,0 +1,52 @@
|
|||
def n 200
|
||||
|
||||
Class AssociativeArray
|
||||
'=====================
|
||||
|
||||
indexbase 1
|
||||
string s[n]
|
||||
sys max
|
||||
|
||||
method find(string k) as sys
|
||||
sys i,e
|
||||
e=max*2
|
||||
for i=1 to e step 2
|
||||
if k=s[i] then return i
|
||||
next
|
||||
end method
|
||||
|
||||
method dat(string k) as string
|
||||
sys i=find(k)
|
||||
if i then return s[i+1]
|
||||
end method
|
||||
|
||||
method dat(string k, d) as sys
|
||||
sys i=find(k)
|
||||
if i=0 then
|
||||
if max>=n
|
||||
print "Array overflow" : return 0
|
||||
end if
|
||||
max+=1
|
||||
i=max*2-1
|
||||
s[i]=k
|
||||
end if
|
||||
s[i+1]=d
|
||||
return i
|
||||
end method
|
||||
|
||||
end class
|
||||
|
||||
|
||||
'====
|
||||
'TEST
|
||||
'====
|
||||
|
||||
AssociativeArray A
|
||||
|
||||
'fill
|
||||
A.s<={"shoes","LC1", "ships","LC2", "sealingwax","LC3", "cabbages","LC4", "kings","LC5"}
|
||||
A.max=5
|
||||
'access
|
||||
print A.dat("ships") 'result LC2
|
||||
A.dat("computers")="LC99" '
|
||||
print A.dat("computers") 'result LC99
|
||||
Loading…
Add table
Add a link
Reference in a new issue