-
Notifications
You must be signed in to change notification settings - Fork 1
/
Table.cs
37 lines (28 loc) · 798 Bytes
/
Table.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
namespace WasmNet.Core;
public class Table
{
private readonly List<Reference> _elements;
public Table(int min, int max)
{
_elements = Enumerable.Repeat(new NullReference(), min).OfType<Reference>().ToList();
Min = min;
Max = max;
}
public IReadOnlyList<Reference> Elements => _elements;
public int Min { get; }
public int Max { get; }
public int Count => _elements.Count;
public void Add(Reference reference)
{
if (_elements.Count >= Max)
{
throw new InvalidOperationException("Table is full");
}
_elements.Add(reference);
}
public Reference this[int index]
{
get => _elements[index];
set => _elements[index] = value;
}
}