annotate toolboxes/FullBNT-1.0.7/KPMtools/hash_del.m @ 0:cc4b1211e677 tip

initial commit to HG from Changeset: 646 (e263d8a21543) added further path and more save "camirversion.m"
author Daniel Wolff
date Fri, 19 Aug 2016 13:07:06 +0200
parents
children
rev   line source
Daniel@0 1 function ndx = hash_del(key, fname)
Daniel@0 2 % HASH_DEL Remove all entries that match key from hashtable stored in a file
Daniel@0 3 % ndx = hash_del(key, fname)
Daniel@0 4 %
Daniel@0 5 % Returns indices of matching entries (if any)
Daniel@0 6 % See hash_lookup for an example
Daniel@0 7
Daniel@0 8 ndx = [];
Daniel@0 9
Daniel@0 10 if ~exist(fname, 'file')
Daniel@0 11 % new hashtable - no op
Daniel@0 12 else
Daniel@0 13 %hashtable = importdata(fname);
Daniel@0 14 %hashtable = load(fname, '-mat');
Daniel@0 15 load(fname, '-mat');
Daniel@0 16 Nentries = length(hashtable.key);
Daniel@0 17 for i=1:Nentries
Daniel@0 18 if isequal(hashtable.key{i}, key)
Daniel@0 19 ndx = [ndx i];
Daniel@0 20 end
Daniel@0 21 end
Daniel@0 22 hashtable.key(ndx) = [];
Daniel@0 23 hashtable.value(ndx) = [];
Daniel@0 24 save(fname, 'hashtable', '-mat');
Daniel@0 25 end
Daniel@0 26