wolffd@0: function ndx = hash_del(key, fname) wolffd@0: % HASH_DEL Remove all entries that match key from hashtable stored in a file wolffd@0: % ndx = hash_del(key, fname) wolffd@0: % wolffd@0: % Returns indices of matching entries (if any) wolffd@0: % See hash_lookup for an example wolffd@0: wolffd@0: ndx = []; wolffd@0: wolffd@0: if ~exist(fname, 'file') wolffd@0: % new hashtable - no op wolffd@0: else wolffd@0: %hashtable = importdata(fname); wolffd@0: %hashtable = load(fname, '-mat'); wolffd@0: load(fname, '-mat'); wolffd@0: Nentries = length(hashtable.key); wolffd@0: for i=1:Nentries wolffd@0: if isequal(hashtable.key{i}, key) wolffd@0: ndx = [ndx i]; wolffd@0: end wolffd@0: end wolffd@0: hashtable.key(ndx) = []; wolffd@0: hashtable.value(ndx) = []; wolffd@0: save(fname, 'hashtable', '-mat'); wolffd@0: end wolffd@0: