IKVM11  11
Java SE 11 Virtual Machine for .NET
Loading...
Searching...
No Matches
Table.cs
Go to the documentation of this file.
1/*
2 Copyright (C) 2009-2012 Jeroen Frijters
3
4 This software is provided 'as-is', without any express or implied
5 warranty. In no event will the authors be held liable for any damages
6 arising from the use of this software.
7
8 Permission is granted to anyone to use this software for any purpose,
9 including commercial applications, and to alter it and redistribute it
10 freely, subject to the following restrictions:
11
12 1. The origin of this software must not be misrepresented; you must not
13 claim that you wrote the original software. If you use this software
14 in a product, an acknowledgment in the product documentation would be
15 appreciated but is not required.
16 2. Altered source versions must be plainly marked as such, and must not be
17 misrepresented as being the original software.
18 3. This notice may not be removed or altered from any source distribution.
19
20 Jeroen Frijters
21 jeroen@frijters.net
22
23*/
24using System;
25
28
30{
31
32 internal abstract class Table
33 {
34
35 internal bool Sorted;
36
37 internal bool IsBig => RowCount > 65535;
38
39 internal abstract int RowCount { get; set; }
40
41 internal abstract void Read(MetadataReader mr);
42
43 internal abstract void Write(ModuleBuilder module);
44
45 }
46
47 abstract class Table<T> : Table
48 {
49
50 internal T[] records = Array.Empty<T>();
51 protected int rowCount;
52
53 internal sealed override int RowCount
54 {
55 get => rowCount;
56 set { rowCount = value; records = new T[value]; }
57 }
58
59 internal int AddRecord(T newRecord)
60 {
61 if (rowCount == records.Length)
62 Array.Resize(ref records, Math.Max(16, records.Length * 2));
63
64 records[rowCount++] = newRecord;
65 return rowCount;
66 }
67
68 internal int AddVirtualRecord()
69 {
70 return ++rowCount;
71 }
72
73 internal override void Write(ModuleBuilder module)
74 {
75
76 }
77
78 }
79
80}