annotate toolboxes/FullBNT-1.0.7/KPMtools/hash_add.m @ 0:e9a9cd732c1e tip

first hg version after svn
author wolffd
date Tue, 10 Feb 2015 15:05:51 +0000
parents
children
rev   line source
wolffd@0 1 function hash_add(key, val, fname)
wolffd@0 2 % HASH_ADD Append key,value pair to end of hashtable stored in a file
wolffd@0 3 % function hash_add(key, val, filename)
wolffd@0 4 %
wolffd@0 5 % See hash_lookup for an example
wolffd@0 6
wolffd@0 7 if ~exist(fname, 'file')
wolffd@0 8 % new hashtable
wolffd@0 9 hashtable.key{1} = key;
wolffd@0 10 hashtable.value{1} = val;
wolffd@0 11 else
wolffd@0 12 %hashtable = importdata(fname);
wolffd@0 13 %hashtable = load(fname, '-mat');
wolffd@0 14 load(fname, '-mat');
wolffd@0 15 Nentries = length(hashtable.key);
wolffd@0 16 hashtable.key{Nentries+1} = key;
wolffd@0 17 hashtable.value{Nentries+1} = val;
wolffd@0 18 end
wolffd@0 19 save(fname, 'hashtable', '-mat');