-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmscorlib.h
More file actions
231 lines (223 loc) · 3.98 KB
/
mscorlib.h
File metadata and controls
231 lines (223 loc) · 3.98 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
#pragma once
template <typename T>
struct Array
{
public:
void* klass;
void* monitor;
void* bounds;
size_t length;
T items[1024];
Array() : klass(nullptr), monitor(nullptr), bounds(nullptr), length(0) {}
T& operator[](size_t index)
{
if (index > length)
throw std::exception("Index out of bounds");
return items[index];
}
T* begin()
{
return items;
}
T* end()
{
return items + length;
}
void clear()
{
length = 0;
}
void push_back(T item)
{
items[length++] = item;
}
void pop_back()
{
length--;
}
T& front()
{
return items[0];
}
T& back()
{
return items[length - 1];
}
bool empty()
{
return length == 0;
}
size_t size()
{
return length;
}
};
namespace System
{
namespace Collections
{
namespace Generic
{
template <typename T>
struct List
{
public:
void* klass;
void* monitor;
Array<T>* items;
int _size;
int _version;
List() : klass(nullptr), monitor(nullptr), items(nullptr), _size(0), _version(0) {}
T& operator[](size_t index)
{
return items->items[index];
}
T* begin()
{
return items->items;
}
T* end()
{
return items->items + _size;
}
void clear()
{
_size = 0;
}
void push_back(T item)
{
items->items[_size++] = item;
}
void pop_back()
{
_size--;
}
T& front()
{
return items->items[0];
}
T& back()
{
return items->items[_size - 1];
}
bool empty()
{
return _size == 0;
}
size_t size()
{
return items->size();
}
};
template <typename TKey, typename TValue>
struct DictionaryEntry
{
void* monitor;
TKey key;
TValue value;
};
template <typename TKey, typename TValue>
struct Dictionary
{
void* klass;
void* monitor;
void* buckets;
Array<DictionaryEntry<TKey, TValue>>* entries;
uint32_t count;
uint32_t version;
uint32_t freeList;
uint32_t freeCount;
void* comparer;
void* keys;
void* values;
unsigned char _syncRoot;
Dictionary() : klass(nullptr), monitor(nullptr), buckets(nullptr), entries(nullptr), count(0), version(0), freeList(0), freeCount(0), comparer(nullptr), keys(nullptr), values(nullptr), _syncRoot(0) {}
TValue& operator[](TKey key)
{
int num = FindEntry(key);
if (num >= 0)
return entries->items[num].value;
throw std::exception("Key not found");
}
int FindEntry(TKey key)
{
if (buckets != nullptr)
{
uint32_t num = (uint32_t)(key.GetHashCode() & 0x7FFFFFFF);
for (int num2 = buckets[num % buckets->length] - 1; num2 >= 0; num2 = entries->items[num2].next)
{
if (entries->items[num2].hashCode == num && entries->items[num2].key == key)
return num2;
}
}
return -1;
}
TValue& GetValueOrDefault(TKey key)
{
int num = FindEntry(key);
if (num >= 0)
return entries->items[num].value;
return TValue();
}
bool ContainsKey(TKey key)
{
return FindEntry(key) >= 0;
}
bool TryGetValue(TKey key, TValue& value)
{
int num = FindEntry(key);
if (num >= 0)
{
value = entries->items[num].value;
return true;
}
value = TValue();
return false;
}
};
template <typename T>
struct HashSetSlot
{
void* monitor;
int hashCode;
int next;
T value;
};
template <typename T>
struct HashSet
{
void* klass;
void* monitor;
void* buckets;
Array<HashSetSlot<T>>* slots;
uint32_t count;
uint32_t lastIndex;
uint32_t freeList;
void* comparer;
int version;
void* siInfo;
};
template <typename T>
struct FastList
{
void* klass;
void* monitor;
Array<T>* Array;
int Count;
int mCapacity;
};
template <typename T>
struct Queue
{
void* klass;
void* monitor;
Array<T>* Array;
int32_t _head;
int32_t _tail;
int32_t _size;
int32_t _version;
void* _syncRoot;
};
}
}
}