Do you use a hash table with buckets or another method to store/look up the elements?
Instructions:
note: the $ suffix is not required if you use DICNEW() or DICREAD() first. Creating/Resetting a dictionary:DIM dictionary$[0] dictionary$=DICNEW() 'or DIM dictionary$[1](The first element stores the locations of all the values, so an "empty" dictionary array will have a length of 1.) Setting a value:
DICSET dictionary$,"key","value"Creates the key if it doesn't exist Getting a value:
value$=DICGET(dictionary$,"key")Returns "" if the key doesn't exist Loading a dictionary from DATA:
dictionary$=DICREAD(@LABEL) @LABEL DATA "key1","value1" DATA "key2","value2" DATA ""Checking if a key exists:
exists=DICCHECK(dictionary$,"key")Returns the location of the value (1 indexed) if the key exists, otherwise 0. Finding the number of keys in a dictionary:
size=DICSIZE(dictionary$)Get a list of keys:
DIM LIST$[0] LIST$=DICLIST(dictionary$)
Notes:
Base functions:'Replace \1 and \0 with CHR$(1) and CHR$(0) 'Add key: INC DIC$[0],CHR$(LEN(DIC$)+1)+"\1"+KEY$+"\0" PUSH DIC$,VAL$ 'Get value: DIC$[ASC(DIC$[0][INSTR(DIC$[0],"\1"+KEY$+"\0")-1])-1]