about summary refs log tree commit diff
path: root/sourcecodes/bnt-master/KPMtools/hash_add.m
blob: f302d8f1577c271f0926d4a3a0d58f8c41674c56 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
function hash_add(key, val, fname)
% HASH_ADD Append key,value pair to end of hashtable stored in a file
% function hash_add(key, val, filename)
%
% See hash_lookup for an example

if ~exist(fname, 'file')
  % new hashtable
  hashtable.key{1} = key;
  hashtable.value{1} = val;
else
  %hashtable = importdata(fname);
  %hashtable = load(fname, '-mat');
  load(fname, '-mat');
  Nentries = length(hashtable.key);
  hashtable.key{Nentries+1} = key;
  hashtable.value{Nentries+1} = val;
end
save(fname, 'hashtable', '-mat');