comparison 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
comparison
equal deleted inserted replaced
-1:000000000000 0:e9a9cd732c1e
1 function hash_add(key, val, fname)
2 % HASH_ADD Append key,value pair to end of hashtable stored in a file
3 % function hash_add(key, val, filename)
4 %
5 % See hash_lookup for an example
6
7 if ~exist(fname, 'file')
8 % new hashtable
9 hashtable.key{1} = key;
10 hashtable.value{1} = val;
11 else
12 %hashtable = importdata(fname);
13 %hashtable = load(fname, '-mat');
14 load(fname, '-mat');
15 Nentries = length(hashtable.key);
16 hashtable.key{Nentries+1} = key;
17 hashtable.value{Nentries+1} = val;
18 end
19 save(fname, 'hashtable', '-mat');