-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathStructureManager.m
52 lines (42 loc) · 1.29 KB
/
StructureManager.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
classdef StructureManager
%STRUCTUREMANAGER Summary of this class goes here
% Detailed explanation goes here
properties
IDToObjTable
end
methods
function obj = StructureManager(size)
obj.IDToObjTable = containers.Map('KeyType', 'int64', 'ValueType', 'any');
end
%Add a material to the list if it doesn't already exist
function obj = put(obj, ID, data)
ID = int64(ID);
m = obj.IDToObjTable;
m(ID) = data;
end
function val = get(obj, ID)
% if ~obj.IDToObjTable.containsKey(ID)
% error('ID not in dictionary')
% end
ID = int64(ID);
m = obj.IDToObjTable;
if isKey(m, ID)
val = m(ID);
else
val = [];
end
end
function obj = remove(obj,ID)
% if ~obj.IDToObjTable.containsKey(ID)
% error('ID not in dictionary')
% end
ID = int64(ID);
m = obj.IDToObjTable;
remove(m, ID);
end
function cells = toCellArray(obj)
m = obj.IDToObjTable;
cells = values(m);
end
end
end