Mercurial > hg > camir-aes2014
annotate toolboxes/FullBNT-1.0.7/KPMtools/hash_del.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 ndx = hash_del(key, fname) |
wolffd@0 | 2 % HASH_DEL Remove all entries that match key from hashtable stored in a file |
wolffd@0 | 3 % ndx = hash_del(key, fname) |
wolffd@0 | 4 % |
wolffd@0 | 5 % Returns indices of matching entries (if any) |
wolffd@0 | 6 % See hash_lookup for an example |
wolffd@0 | 7 |
wolffd@0 | 8 ndx = []; |
wolffd@0 | 9 |
wolffd@0 | 10 if ~exist(fname, 'file') |
wolffd@0 | 11 % new hashtable - no op |
wolffd@0 | 12 else |
wolffd@0 | 13 %hashtable = importdata(fname); |
wolffd@0 | 14 %hashtable = load(fname, '-mat'); |
wolffd@0 | 15 load(fname, '-mat'); |
wolffd@0 | 16 Nentries = length(hashtable.key); |
wolffd@0 | 17 for i=1:Nentries |
wolffd@0 | 18 if isequal(hashtable.key{i}, key) |
wolffd@0 | 19 ndx = [ndx i]; |
wolffd@0 | 20 end |
wolffd@0 | 21 end |
wolffd@0 | 22 hashtable.key(ndx) = []; |
wolffd@0 | 23 hashtable.value(ndx) = []; |
wolffd@0 | 24 save(fname, 'hashtable', '-mat'); |
wolffd@0 | 25 end |
wolffd@0 | 26 |