Code written by Nick Konidaris
WARNING: This code is /SLOW/!
function create_hash
return, {hash: 0}
end
function add_to_hash, $
hash,$ ; A structure
name, $ ; The name of the variable
value ; The value for that variable to have
if n_tags(hash) gt 5000 then return, hash
vars = tag_names(hash)
ix = where(strupcase(name) eq vars, count)
if count eq 0 then begin
hash = create_struct(hash, name, value)
endif else begin
hash.(ix) = value
endelse
return, hash
end
function hash_lookup,$
hash, $ ; Hash structure
name, $ ; Name in the hash
status=status ; did we succeed?
vars = tag_names(hash)
ix = where(strupcase(name) eq vars, count)
if count eq 0 then begin
status = -1
return, !values.f_nan
endif
status = 1
return, hash.(ix)
end
