-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIL2CppDictionary.h
123 lines (103 loc) · 2.31 KB
/
IL2CppDictionary.h
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
#include "monoArray.h"
template<typename TKey, typename TValue>
struct Dictionary {
struct KeysCollection;
struct ValueCollection;
struct Entry
{
int hashCode;
int next;
TKey key;
TValue value;
};
void *kass;
void *monitor;
monoArray<int *> *buckets;
monoArray<Entry *> *entries;
int count;
int version;
int freeList;
int freeCount;
void* comparer;
KeysCollection *keys;
ValueCollection *values;
void *_syncRoot;
void* get_Comparer(){
return comparer;
}
int get_Count(){
return (count - freeCount);
}
KeysCollection get_Keys(){
if(!keys){
keys = new KeysCollection;
keys->dictionary = this;
}
return (*keys);
}
ValueCollection get_Values(){
if(!values){
values = new ValueCollection;
values->dictionary = this;
}
return (*values);
}
TValue operator [] (TKey key) {
int i = FindEntry(key);
if (i >= 0) return entries->getPointer()[i].value;
return TValue();
}
const TValue operator [] (TKey key) const {
int i = FindEntry(key);
if (i >= 0) return entries->getPointer()[i].value;
return TValue();
}
int FindEntry(TKey key) {
for (int i = 0; i < count; i++){
if(entries->getPointer()[i].key == key) return i;
}
return -1;
}
bool ContainsKey(TKey key) {
return FindEntry(key) >= 0;
}
bool ContainsValue(TValue value) {
for (int i = 0; i < count; i++){
if(entries->getPointer()[i].hashCode >= 0 &&
entries->getPointer()[i].value == value) return true;
}
return false;
}
struct KeysCollection {
void *kass;
void *monitor;
Dictionary<TKey, TValue> *dictionary;
TKey operator [] (int i) {
if(dictionary->entries)return dictionary->entries->getPointer()[i].key;
return TKey();
}
const TKey operator [] (int i) const {
if(dictionary->entries)return dictionary->entries->getPointer()[i].key;
return TKey();
}
int get_Count(){
return dictionary->count();
}
};
struct ValueCollection {
void *kass;
void *monitor;
Dictionary<TKey, TValue> *dictionary;
TValue operator [] (int i) {
if(dictionary->entries)return dictionary->entries->getPointer()[i].value;
return TValue();
}
const TValue operator [] (int i) const {
if(dictionary->entries)return dictionary->entries->getPointer()[i].value;
return TValue();
}
int get_Count(){
return dictionary->count();
}
};
};