classdef nDimHashTable
properties (Access = private)
c = {}
end
methods (Access = public)
function this = nDimHashTable()
this.c = {};
end
function this = clear(this)
this.c = {};
end
function out = size(this)
out = sum(~isempty(this.c), 'all');
end
function this = subsasgn(this, key, value)
if key.type ~= "()"
error('Unrecognized property: %s', key.subs)
end
indices = nDimHashTable.hash(key.subs);
this.c{indices{:}} = value;
end
function out = subsref(this, key)
if key.type ~= "()"
error('Unrecognized property: %s', key.subs)
end
indices = nDimHashTable.hash(key.subs);
out = [this.c{indices{:}}];
end
end
methods (Static)
function out = hash(in)
out = {};
for key = string(in)
if key == ":"
out{end+1} = ':';
else
out{end+1} = mod(hex2dec(rptgen.hash(key)), 1979);
end
end
end
end
end