-
Notifications
You must be signed in to change notification settings - Fork 3
/
ElementsMap.cs
48 lines (38 loc) · 937 Bytes
/
ElementsMap.cs
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
using System.Collections.Generic;
using System.Diagnostics;
namespace RevitGltfExporter
{
public class ElementsMap<ID, T> : ElementsSet<T>
{
private Dictionary<ID, int> map = new Dictionary<ID, int>();
public int indexOf(ID id)
{
if(map.ContainsKey(id))
return map[id];
return -1;
}
public T getById(ID id)
{
return at(map[id]);
}
public bool exists(ID id)
{
return map.ContainsKey(id);
}
public int add(ID id, T element)
{
if (map.ContainsKey(id))
{
return indexOf(id);
}
int index = base.add(element);
map.Add(id, index);
return index;
}
override public void dispose()
{
map.Clear();
base.dispose();
}
}
}