wasSharp – Blame information for rev
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
22 | office | 1 | /////////////////////////////////////////////////////////////////////////// |
2 | // Copyright (C) Wizardry and Steamworks 2016 - License: GNU GPLv3 // |
||
3 | // Please see: http://www.gnu.org/licenses/gpl.html for legal details, // |
||
4 | // rights of fair usage, the disclaimer and warranty conditions. // |
||
5 | /////////////////////////////////////////////////////////////////////////// |
||
6 | // Based on the work of Herman Schoenfeld |
||
7 | |||
8 | using System; |
||
9 | using System.Collections.Generic; |
||
10 | using System.Linq; |
||
11 | |||
12 | namespace wasSharp.Collections.Specialized |
||
13 | { |
||
14 | public class MultiKeyDictionary<K1, K2, V> : Dictionary<K1, Dictionary<K2, V>> |
||
15 | { |
||
16 | public V this[K1 key1, K2 key2] |
||
17 | { |
||
18 | get |
||
19 | { |
||
20 | if (!ContainsKey(key1) || !this[key1].ContainsKey(key2)) |
||
21 | throw new ArgumentOutOfRangeException(); |
||
22 | return base[key1][key2]; |
||
23 | } |
||
24 | set |
||
25 | { |
||
26 | if (!ContainsKey(key1)) |
||
27 | this[key1] = new Dictionary<K2, V>(); |
||
28 | this[key1][key2] = value; |
||
29 | } |
||
30 | } |
||
31 | |||
32 | public new IEnumerable<V> Values |
||
33 | { |
||
34 | get |
||
35 | { |
||
36 | return from baseDict in base.Values |
||
37 | from baseKey in baseDict.Keys |
||
38 | select baseDict[baseKey]; |
||
39 | } |
||
40 | } |
||
41 | |||
42 | public void Add(K1 key1, K2 key2, V value) |
||
43 | { |
||
44 | if (!ContainsKey(key1)) |
||
45 | this[key1] = new Dictionary<K2, V>(); |
||
46 | this[key1][key2] = value; |
||
47 | } |
||
48 | |||
49 | public bool ContainsKey(K1 key1, K2 key2) |
||
50 | { |
||
51 | return base.ContainsKey(key1) && this[key1].ContainsKey(key2); |
||
52 | } |
||
53 | } |
||
54 | |||
55 | public class MultiKeyDictionary<K1, K2, K3, V> : Dictionary<K1, MultiKeyDictionary<K2, K3, V>> |
||
56 | { |
||
57 | public V this[K1 key1, K2 key2, K3 key3] |
||
58 | { |
||
59 | get { return ContainsKey(key1) ? this[key1][key2, key3] : default(V); } |
||
60 | set |
||
61 | { |
||
62 | if (!ContainsKey(key1)) |
||
63 | this[key1] = new MultiKeyDictionary<K2, K3, V>(); |
||
64 | this[key1][key2, key3] = value; |
||
65 | } |
||
66 | } |
||
67 | |||
68 | public bool ContainsKey(K1 key1, K2 key2, K3 key3) |
||
69 | { |
||
70 | return base.ContainsKey(key1) && this[key1].ContainsKey(key2, key3); |
||
71 | } |
||
72 | } |
||
73 | |||
74 | public class MultiKeyDictionary<K1, K2, K3, K4, V> : Dictionary<K1, MultiKeyDictionary<K2, K3, K4, V>> |
||
75 | { |
||
76 | public V this[K1 key1, K2 key2, K3 key3, K4 key4] |
||
77 | { |
||
78 | get { return ContainsKey(key1) ? this[key1][key2, key3, key4] : default(V); } |
||
79 | set |
||
80 | { |
||
81 | if (!ContainsKey(key1)) |
||
82 | this[key1] = new MultiKeyDictionary<K2, K3, K4, V>(); |
||
83 | this[key1][key2, key3, key4] = value; |
||
84 | } |
||
85 | } |
||
86 | |||
87 | public bool ContainsKey(K1 key1, K2 key2, K3 key3, K4 key4) |
||
88 | { |
||
89 | return base.ContainsKey(key1) && this[key1].ContainsKey(key2, key3, key4); |
||
90 | } |
||
91 | } |
||
92 | |||
93 | public class MultiKeyDictionary<K1, K2, K3, K4, K5, V> : Dictionary<K1, MultiKeyDictionary<K2, K3, K4, K5, V>> |
||
94 | { |
||
95 | public V this[K1 key1, K2 key2, K3 key3, K4 key4, K5 key5] |
||
96 | { |
||
97 | get { return ContainsKey(key1) ? this[key1][key2, key3, key4, key5] : default(V); } |
||
98 | set |
||
99 | { |
||
100 | if (!ContainsKey(key1)) |
||
101 | this[key1] = new MultiKeyDictionary<K2, K3, K4, K5, V>(); |
||
102 | this[key1][key2, key3, key4, key5] = value; |
||
103 | } |
||
104 | } |
||
105 | |||
106 | public bool ContainsKey(K1 key1, K2 key2, K3 key3, K4 key4, K5 key5) |
||
107 | { |
||
108 | return base.ContainsKey(key1) && this[key1].ContainsKey(key2, key3, key4, key5); |
||
109 | } |
||
110 | } |
||
111 | |||
112 | public class MultiKeyDictionary<K1, K2, K3, K4, K5, K6, V> : |
||
113 | Dictionary<K1, MultiKeyDictionary<K2, K3, K4, K5, K6, V>> |
||
114 | { |
||
115 | public V this[K1 key1, K2 key2, K3 key3, K4 key4, K5 key5, K6 key6] |
||
116 | { |
||
117 | get { return ContainsKey(key1) ? this[key1][key2, key3, key4, key5, key6] : default(V); } |
||
118 | set |
||
119 | { |
||
120 | if (!ContainsKey(key1)) |
||
121 | this[key1] = new MultiKeyDictionary<K2, K3, K4, K5, K6, V>(); |
||
122 | this[key1][key2, key3, key4, key5, key6] = value; |
||
123 | } |
||
124 | } |
||
125 | |||
126 | public bool ContainsKey(K1 key1, K2 key2, K3 key3, K4 key4, K5 key5, K6 key6) |
||
127 | { |
||
128 | return base.ContainsKey(key1) && this[key1].ContainsKey(key2, key3, key4, key5, key6); |
||
129 | } |
||
130 | } |
||
131 | |||
132 | public class MultiKeyDictionary<K1, K2, K3, K4, K5, K6, K7, V> : |
||
133 | Dictionary<K1, MultiKeyDictionary<K2, K3, K4, K5, K6, K7, V>> |
||
134 | { |
||
135 | public V this[K1 key1, K2 key2, K3 key3, K4 key4, K5 key5, K6 key6, K7 key7] |
||
136 | { |
||
137 | get { return ContainsKey(key1) ? this[key1][key2, key3, key4, key5, key6, key7] : default(V); } |
||
138 | set |
||
139 | { |
||
140 | if (!ContainsKey(key1)) |
||
141 | this[key1] = new MultiKeyDictionary<K2, K3, K4, K5, K6, K7, V>(); |
||
142 | this[key1][key2, key3, key4, key5, key6, key7] = value; |
||
143 | } |
||
144 | } |
||
145 | |||
146 | public bool ContainsKey(K1 key1, K2 key2, K3 key3, K4 key4, K5 key5, K6 key6, K7 key7) |
||
147 | { |
||
148 | return base.ContainsKey(key1) && this[key1].ContainsKey(key2, key3, key4, key5, key6, key7); |
||
149 | } |
||
150 | } |
||
151 | |||
152 | public class MultiKeyDictionary<K1, K2, K3, K4, K5, K6, K7, K8, V> : |
||
153 | Dictionary<K1, MultiKeyDictionary<K2, K3, K4, K5, K6, K7, K8, V>> |
||
154 | { |
||
155 | public V this[K1 key1, K2 key2, K3 key3, K4 key4, K5 key5, K6 key6, K7 key7, K8 key8] |
||
156 | { |
||
157 | get { return ContainsKey(key1) ? this[key1][key2, key3, key4, key5, key6, key7, key8] : default(V); } |
||
158 | set |
||
159 | { |
||
160 | if (!ContainsKey(key1)) |
||
161 | this[key1] = new MultiKeyDictionary<K2, K3, K4, K5, K6, K7, K8, V>(); |
||
162 | this[key1][key2, key3, key4, key5, key6, key7, key8] = value; |
||
163 | } |
||
164 | } |
||
165 | |||
166 | public bool ContainsKey(K1 key1, K2 key2, K3 key3, K4 key4, K5 key5, K6 key6, K7 key7, K8 key8) |
||
167 | { |
||
168 | return base.ContainsKey(key1) && this[key1].ContainsKey(key2, key3, key4, key5, key6, key7, key8); |
||
169 | } |
||
170 | } |
||
171 | |||
172 | public class MultiKeyDictionary<K1, K2, K3, K4, K5, K6, K7, K8, K9, V> : |
||
173 | Dictionary<K1, MultiKeyDictionary<K2, K3, K4, K5, K6, K7, K8, K9, V>> |
||
174 | { |
||
175 | public V this[K1 key1, K2 key2, K3 key3, K4 key4, K5 key5, K6 key6, K7 key7, K8 key8, K9 key9] |
||
176 | { |
||
177 | get { return ContainsKey(key1) ? this[key1][key2, key3, key4, key5, key6, key7, key8, key9] : default(V); } |
||
178 | set |
||
179 | { |
||
180 | if (!ContainsKey(key1)) |
||
181 | this[key1] = new MultiKeyDictionary<K2, K3, K4, K5, K6, K7, K8, K9, V>(); |
||
182 | this[key1][key2, key3, key4, key5, key6, key7, key8, key9] = value; |
||
183 | } |
||
184 | } |
||
185 | |||
186 | public bool ContainsKey(K1 key1, K2 key2, K3 key3, K4 key4, K5 key5, K6 key6, K7 key7, K8 key8, K9 key9) |
||
187 | { |
||
188 | return base.ContainsKey(key1) && this[key1].ContainsKey(key2, key3, key4, key5, key6, key7, key8, key9); |
||
189 | } |
||
190 | } |
||
191 | |||
192 | public class MultiKeyDictionary<K1, K2, K3, K4, K5, K6, K7, K8, K9, K10, V> : |
||
193 | Dictionary<K1, MultiKeyDictionary<K2, K3, K4, K5, K6, K7, K8, K9, K10, V>> |
||
194 | { |
||
195 | public V this[K1 key1, K2 key2, K3 key3, K4 key4, K5 key5, K6 key6, K7 key7, K8 key8, K9 key9, K10 key10] |
||
196 | { |
||
197 | get |
||
198 | { |
||
199 | return ContainsKey(key1) ? this[key1][key2, key3, key4, key5, key6, key7, key8, key9, key10] : default(V); |
||
200 | } |
||
201 | set |
||
202 | { |
||
203 | if (!ContainsKey(key1)) |
||
204 | this[key1] = new MultiKeyDictionary<K2, K3, K4, K5, K6, K7, K8, K9, K10, V>(); |
||
205 | this[key1][key2, key3, key4, key5, key6, key7, key8, key9, key10] = value; |
||
206 | } |
||
207 | } |
||
208 | |||
209 | public bool ContainsKey(K1 key1, K2 key2, K3 key3, K4 key4, K5 key5, K6 key6, K7 key7, K8 key8, K9 key9, |
||
210 | K10 key10) |
||
211 | { |
||
212 | return base.ContainsKey(key1) && |
||
213 | this[key1].ContainsKey(key2, key3, key4, key5, key6, key7, key8, key9, key10); |
||
214 | } |
||
215 | } |
||
216 | |||
217 | public class MultiKeyDictionary<K1, K2, K3, K4, K5, K6, K7, K8, K9, K10, K11, V> : |
||
218 | Dictionary<K1, MultiKeyDictionary<K2, K3, K4, K5, K6, K7, K8, K9, K10, K11, V>> |
||
219 | { |
||
220 | public V this[ |
||
221 | K1 key1, K2 key2, K3 key3, K4 key4, K5 key5, K6 key6, K7 key7, K8 key8, K9 key9, K10 key10, K11 key11] |
||
222 | { |
||
223 | get |
||
224 | { |
||
225 | return ContainsKey(key1) |
||
226 | ? this[key1][key2, key3, key4, key5, key6, key7, key8, key9, key10, key11] |
||
227 | : default(V); |
||
228 | } |
||
229 | set |
||
230 | { |
||
231 | if (!ContainsKey(key1)) |
||
232 | this[key1] = new MultiKeyDictionary<K2, K3, K4, K5, K6, K7, K8, K9, K10, K11, V>(); |
||
233 | this[key1][key2, key3, key4, key5, key6, key7, key8, key9, key10, key11] = value; |
||
234 | } |
||
235 | } |
||
236 | |||
237 | public bool ContainsKey(K1 key1, K2 key2, K3 key3, K4 key4, K5 key5, K6 key6, K7 key7, K8 key8, K9 key9, |
||
238 | K10 key10, K11 key11) |
||
239 | { |
||
240 | return base.ContainsKey(key1) && |
||
241 | this[key1].ContainsKey(key2, key3, key4, key5, key6, key7, key8, key9, key10, key11); |
||
242 | } |
||
243 | } |
||
244 | } |