wasSharp – Diff between revs 27 and 39
?pathlinks?
Rev 27 | Rev 39 | |||
---|---|---|---|---|
Line 3... | Line 3... | |||
3 | // Please see: http://www.gnu.org/licenses/gpl.html for legal details, // |
3 | // Please see: http://www.gnu.org/licenses/gpl.html for legal details, // |
|
4 | // rights of fair usage, the disclaimer and warranty conditions. // |
4 | // rights of fair usage, the disclaimer and warranty conditions. // |
|
5 | /////////////////////////////////////////////////////////////////////////// |
5 | /////////////////////////////////////////////////////////////////////////// |
|
6 | // Based on the work of Herman Schoenfeld |
6 | // Based on the work of Herman Schoenfeld |
|
Line 7... | Line -... | |||
7 | |
- | ||
8 | using System; |
7 | |
|
9 | using System.Collections.Generic; |
8 | using System.Collections.Generic; |
|
- | 9 | using System.Linq; |
||
Line 10... | Line 10... | |||
10 | using System.Linq; |
10 | using System.Threading; |
|
11 | |
11 | |
|
12 | namespace wasSharp.Collections.Specialized |
12 | namespace wasSharp.Collections.Specialized |
|
13 | { |
13 | { |
|
- | 14 | public class MultiKeyDictionary<K1, K2, V> : Dictionary<K1, Dictionary<K2, V>> |
||
- | 15 | { |
||
14 | public class MultiKeyDictionary<K1, K2, V> : Dictionary<K1, Dictionary<K2, V>> |
16 | private readonly ReaderWriterLockSlim SyncRoot = new ReaderWriterLockSlim(LockRecursionPolicy.SupportsRecursion); |
|
15 | { |
17 | |
|
16 | public V this[K1 key1, K2 key2] |
18 | public V this[K1 key1, K2 key2] |
|
17 | { |
19 | { |
|
- | 20 | get |
||
18 | get |
21 | { |
|
- | 22 | SyncRoot.EnterReadLock(); |
||
- | 23 | if (!ContainsKey(key1) || !this[key1].ContainsKey(key2)) |
||
19 | { |
24 | { |
|
- | 25 | SyncRoot.ExitReadLock(); |
||
20 | if (!ContainsKey(key1) || !this[key1].ContainsKey(key2)) |
26 | return default(V); |
|
- | 27 | } |
||
- | 28 | var v = base[key1][key2]; |
||
21 | throw new ArgumentOutOfRangeException(); |
29 | SyncRoot.ExitReadLock(); |
|
22 | return base[key1][key2]; |
30 | return v; |
|
23 | } |
31 | } |
|
- | 32 | set |
||
24 | set |
33 | { |
|
25 | { |
34 | SyncRoot.EnterWriteLock(); |
|
- | 35 | if (!ContainsKey(key1)) |
||
26 | if (!ContainsKey(key1)) |
36 | this[key1] = new Dictionary<K2, V>(); |
|
- | 37 | |
||
27 | this[key1] = new Dictionary<K2, V>(); |
38 | this[key1][key2] = value; |
|
28 | this[key1][key2] = value; |
39 | SyncRoot.ExitWriteLock(); |
|
Line 29... | Line 40... | |||
29 | } |
40 | } |
|
- | 41 | } |
||
- | 42 | |
||
- | 43 | public new IEnumerable<V> Values |
||
- | 44 | { |
||
30 | } |
45 | get |
|
- | 46 | { |
||
- | 47 | SyncRoot.EnterReadLock(); |
||
- | 48 | var v = base.Values.SelectMany(baseDict => baseDict.Keys, (baseDict, baseKey) => baseDict[baseKey]); |
||
- | 49 | SyncRoot.ExitReadLock(); |
||
Line 31... | Line 50... | |||
31 | |
50 | return v; |
|
32 | public new IEnumerable<V> Values => |
51 | } |
|
- | 52 | } |
||
33 | base.Values.SelectMany(baseDict => baseDict.Keys, (baseDict, baseKey) => baseDict[baseKey]); |
53 | |
|
34 | |
54 | public void Add(K1 key1, K2 key2, V value) |
|
- | 55 | { |
||
35 | public void Add(K1 key1, K2 key2, V value) |
56 | SyncRoot.EnterWriteLock(); |
|
- | 57 | if (!ContainsKey(key1)) |
||
36 | { |
58 | this[key1] = new Dictionary<K2, V>(); |
|
Line 37... | Line 59... | |||
37 | if (!ContainsKey(key1)) |
59 | |
|
38 | this[key1] = new Dictionary<K2, V>(); |
60 | this[key1][key2] = value; |
|
- | 61 | SyncRoot.ExitWriteLock(); |
||
39 | this[key1][key2] = value; |
62 | } |
|
- | 63 | |
||
- | 64 | public void Remove(K1 key1, K2 key2) |
||
40 | } |
65 | { |
|
- | 66 | SyncRoot.EnterWriteLock(); |
||
41 | |
67 | if (!ContainsKey(key1) || !this[key1].ContainsKey(key2)) |
|
42 | public void Remove(K1 key1, K2 key2) |
68 | { |
|
- | 69 | SyncRoot.ExitWriteLock(); |
||
43 | { |
70 | return; |
|
Line 44... | Line 71... | |||
44 | if (!ContainsKey(key1) || !this[key1].ContainsKey(key2)) |
71 | } |
|
45 | return; |
72 | this[key1].Remove(key2); |
|
- | 73 | Remove(key1); |
||
46 | this[key1].Remove(key2); |
74 | SyncRoot.ExitWriteLock(); |
|
- | 75 | } |
||
- | 76 | |
||
47 | Remove(key1); |
77 | public bool ContainsKey(K1 key1, K2 key2) |
|
Line 48... | Line 78... | |||
48 | } |
78 | { |
|
49 | |
79 | SyncRoot.EnterReadLock(); |
|
- | 80 | var c = ContainsKey(key1) && this[key1].ContainsKey(key2); |
||
50 | public bool ContainsKey(K1 key1, K2 key2) |
81 | SyncRoot.ExitReadLock(); |
|
51 | { |
82 | return c; |
|
- | 83 | } |
||
52 | return ContainsKey(key1) && this[key1].ContainsKey(key2); |
84 | |
|
53 | } |
85 | public bool TryGetValue(K1 key1, K2 key2, out V value) |
|
54 | |
86 | { |
|
55 | public bool TryGetValue(K1 key1, K2 key2, out V value) |
87 | SyncRoot.EnterReadLock(); |
|
- | 88 | if (!ContainsKey(key1) || !this[key1].ContainsKey(key2)) |
||
56 | { |
89 | { |
|
57 | if (!ContainsKey(key1) || !this[key1].ContainsKey(key2)) |
90 | SyncRoot.ExitReadLock(); |
|
58 | { |
91 | value = default(V); |
|
Line 59... | Line 92... | |||
59 | value = default(V); |
92 | return false; |
|
60 | return false; |
93 | } |
|
- | 94 | value = base[key1][key2]; |
||
- | 95 | SyncRoot.ExitReadLock(); |
||
61 | } |
96 | return true; |
|
62 | value = base[key1][key2]; |
97 | } |
|
- | 98 | } |
||
- | 99 | |
||
- | 100 | public class MultiKeyDictionary<K1, K2, K3, V> : Dictionary<K1, MultiKeyDictionary<K2, K3, V>> |
||
63 | return true; |
101 | { |
|
- | 102 | private readonly ReaderWriterLockSlim SyncRoot = new ReaderWriterLockSlim(LockRecursionPolicy.SupportsRecursion); |
||
- | 103 | |
||
- | 104 | public V this[K1 key1, K2 key2, K3 key3] |
||
64 | } |
105 | { |
|
65 | } |
106 | get |
|
- | 107 | { |
||
66 | |
108 | SyncRoot.EnterReadLock(); |
|
67 | public class MultiKeyDictionary<K1, K2, K3, V> : Dictionary<K1, MultiKeyDictionary<K2, K3, V>> |
109 | var v = ContainsKey(key1) ? this[key1][key2, key3] : default(V); |
|
68 | { |
110 | SyncRoot.ExitReadLock(); |
|
- | 111 | return v; |
||
69 | public V this[K1 key1, K2 key2, K3 key3] |
112 | } |
|
70 | { |
113 | set |
|
Line 71... | Line 114... | |||
71 | get { return ContainsKey(key1) ? this[key1][key2, key3] : default(V); } |
114 | { |
|
72 | set |
115 | SyncRoot.EnterWriteLock(); |
|
- | 116 | if (!ContainsKey(key1)) |
||
73 | { |
117 | this[key1] = new MultiKeyDictionary<K2, K3, V>(); |
|
- | 118 | this[key1][key2, key3] = value; |
||
- | 119 | SyncRoot.ExitWriteLock(); |
||
74 | if (!ContainsKey(key1)) |
120 | } |
|
Line 75... | Line 121... | |||
75 | this[key1] = new MultiKeyDictionary<K2, K3, V>(); |
121 | } |
|
76 | this[key1][key2, key3] = value; |
122 | |
|
- | 123 | public bool ContainsKey(K1 key1, K2 key2, K3 key3) |
||
77 | } |
124 | { |
|
78 | } |
125 | SyncRoot.EnterReadLock(); |
|
79 | |
126 | var c = ContainsKey(key1) && this[key1].ContainsKey(key2, key3); |
|
- | 127 | SyncRoot.ExitReadLock(); |
||
80 | public bool ContainsKey(K1 key1, K2 key2, K3 key3) |
128 | return c; |
|
Line 81... | Line 129... | |||
81 | { |
129 | } |
|
82 | return ContainsKey(key1) && this[key1].ContainsKey(key2, key3); |
130 | |
|
- | 131 | public void Add(K1 key1, K2 key2, K3 key3, V value) |
||
83 | } |
132 | { |
|
- | 133 | SyncRoot.EnterWriteLock(); |
||
- | 134 | if (!ContainsKey(key1)) |
||
84 | |
135 | this[key1] = new MultiKeyDictionary<K2, K3, V>(); |
|
- | 136 | this[key1][key2, key3] = value; |
||
85 | public void Add(K1 key1, K2 key2, K3 key3, V value) |
137 | SyncRoot.ExitWriteLock(); |
|
86 | { |
138 | } |
|
87 | if (!ContainsKey(key1)) |
139 | |
|
- | 140 | public void Remove(K1 key1, K2 key2, K3 key3) |
||
88 | this[key1] = new MultiKeyDictionary<K2, K3, V>(); |
141 | { |
|
Line 89... | Line 142... | |||
89 | this[key1][key2, key3] = value; |
142 | SyncRoot.EnterWriteLock(); |
|
90 | } |
143 | if (!ContainsKey(key1) || !this[key1].ContainsKey(key2, key3)) |
|
- | 144 | { |
||
91 | |
145 | SyncRoot.ExitWriteLock(); |
|
92 | public void Remove(K1 key1, K2 key2, K3 key3) |
146 | return; |
|
- | 147 | } |
||
93 | { |
148 | this[key1][key2].Remove(key3); |
|
94 | if (!ContainsKey(key1) || !this[key1].ContainsKey(key2, key3)) |
149 | this[key1].Remove(key2); |
|
95 | return; |
150 | Remove(key1); |
|
96 | this[key1][key2].Remove(key3); |
151 | SyncRoot.ExitWriteLock(); |
|
- | 152 | } |
||
97 | this[key1].Remove(key2); |
153 | |
|
98 | Remove(key1); |
154 | public bool TryGetValue(K1 key1, K2 key2, K3 key3, out V value) |
|
99 | } |
155 | { |
|
Line 100... | Line 156... | |||
100 | |
156 | SyncRoot.EnterReadLock(); |
|
101 | public bool TryGetValue(K1 key1, K2 key2, K3 key3, out V value) |
157 | if (!ContainsKey(key1) || !this[key1].ContainsKey(key2, key3)) |
|
- | 158 | { |
||
- | 159 | SyncRoot.ExitReadLock(); |
||
102 | { |
160 | value = default(V); |
|
103 | if (!ContainsKey(key1) || !this[key1].ContainsKey(key2, key3)) |
161 | return false; |
|
- | 162 | } |
||
- | 163 | value = base[key1][key2, key3]; |
||
- | 164 | SyncRoot.ExitReadLock(); |
||
104 | { |
165 | return true; |
|
- | 166 | } |
||
- | 167 | } |
||
- | 168 | |
||
105 | value = default(V); |
169 | public class MultiKeyDictionary<K1, K2, K3, K4, V> : Dictionary<K1, MultiKeyDictionary<K2, K3, K4, V>> |
|
106 | return false; |
170 | { |
|
- | 171 | private readonly ReaderWriterLockSlim SyncRoot = new ReaderWriterLockSlim(LockRecursionPolicy.SupportsRecursion); |
||
107 | } |
172 | |
|
108 | value = base[key1][key2, key3]; |
173 | public V this[K1 key1, K2 key2, K3 key3, K4 key4] |
|
109 | return true; |
174 | { |
|
- | 175 | get |
||
110 | } |
176 | { |
|
111 | } |
177 | SyncRoot.EnterReadLock(); |
|
Line 112... | Line 178... | |||
112 | |
178 | var v = ContainsKey(key1) ? this[key1][key2, key3, key4] : default(V); |
|
113 | public class MultiKeyDictionary<K1, K2, K3, K4, V> : Dictionary<K1, MultiKeyDictionary<K2, K3, K4, V>> |
179 | SyncRoot.ExitReadLock(); |
|
- | 180 | return v; |
||
114 | { |
181 | } |
|
- | 182 | set |
||
- | 183 | { |
||
115 | public V this[K1 key1, K2 key2, K3 key3, K4 key4] |
184 | SyncRoot.EnterWriteLock(); |
|
116 | { |
185 | if (!ContainsKey(key1)) |
|
Line 117... | Line 186... | |||
117 | get { return ContainsKey(key1) ? this[key1][key2, key3, key4] : default(V); } |
186 | this[key1] = new MultiKeyDictionary<K2, K3, K4, V>(); |
|
118 | set |
187 | this[key1][key2, key3, key4] = value; |
|
- | 188 | SyncRoot.ExitWriteLock(); |
||
- | 189 | } |
||
119 | { |
190 | } |
|
120 | if (!ContainsKey(key1)) |
191 | |
|
- | 192 | public bool ContainsKey(K1 key1, K2 key2, K3 key3, K4 key4) |
||
- | 193 | { |
||
- | 194 | SyncRoot.EnterReadLock(); |
||
121 | this[key1] = new MultiKeyDictionary<K2, K3, K4, V>(); |
195 | var c = ContainsKey(key1) && this[key1].ContainsKey(key2, key3, key4); |
|
- | 196 | SyncRoot.ExitReadLock(); |
||
- | 197 | return c; |
||
- | 198 | } |
||
122 | this[key1][key2, key3, key4] = value; |
199 | } |
|
123 | } |
200 | |
|
- | 201 | public class MultiKeyDictionary<K1, K2, K3, K4, K5, V> : Dictionary<K1, MultiKeyDictionary<K2, K3, K4, K5, V>> |
||
124 | } |
202 | { |
|
125 | |
203 | private readonly ReaderWriterLockSlim SyncRoot = new ReaderWriterLockSlim(LockRecursionPolicy.SupportsRecursion); |
|
126 | public bool ContainsKey(K1 key1, K2 key2, K3 key3, K4 key4) |
204 | |
|
- | 205 | public V this[K1 key1, K2 key2, K3 key3, K4 key4, K5 key5] |
||
127 | { |
206 | { |
|
128 | return ContainsKey(key1) && this[key1].ContainsKey(key2, key3, key4); |
207 | get |
|
Line 129... | Line 208... | |||
129 | } |
208 | { |
|
130 | } |
209 | SyncRoot.EnterReadLock(); |
|
- | 210 | var v = ContainsKey(key1) ? this[key1][key2, key3, key4, key5] : default(V); |
||
131 | |
211 | SyncRoot.ExitReadLock(); |
|
- | 212 | return v; |
||
- | 213 | } |
||
132 | public class MultiKeyDictionary<K1, K2, K3, K4, K5, V> : Dictionary<K1, MultiKeyDictionary<K2, K3, K4, K5, V>> |
214 | set |
|
133 | { |
215 | { |
|
Line 134... | Line 216... | |||
134 | public V this[K1 key1, K2 key2, K3 key3, K4 key4, K5 key5] |
216 | SyncRoot.EnterWriteLock(); |
|
135 | { |
217 | if (!ContainsKey(key1)) |
|
136 | get { return ContainsKey(key1) ? this[key1][key2, key3, key4, key5] : default(V); } |
218 | this[key1] = new MultiKeyDictionary<K2, K3, K4, K5, V>(); |
|
- | 219 | this[key1][key2, key3, key4, key5] = value; |
||
- | 220 | SyncRoot.ExitWriteLock(); |
||
137 | set |
221 | } |
|
138 | { |
222 | } |
|
- | 223 | |
||
- | 224 | public bool ContainsKey(K1 key1, K2 key2, K3 key3, K4 key4, K5 key5) |
||
- | 225 | { |
||
139 | if (!ContainsKey(key1)) |
226 | SyncRoot.EnterReadLock(); |
|
- | 227 | var c = ContainsKey(key1) && this[key1].ContainsKey(key2, key3, key4, key5); |
||
- | 228 | SyncRoot.ExitReadLock(); |
||
- | 229 | return c; |
||
140 | this[key1] = new MultiKeyDictionary<K2, K3, K4, K5, V>(); |
230 | } |
|
141 | this[key1][key2, key3, key4, key5] = value; |
231 | } |
|
- | 232 | |
||
142 | } |
233 | public class MultiKeyDictionary<K1, K2, K3, K4, K5, K6, V> : |
|
143 | } |
234 | Dictionary<K1, MultiKeyDictionary<K2, K3, K4, K5, K6, V>> |
|
144 | |
235 | { |
|
- | 236 | private readonly ReaderWriterLockSlim SyncRoot = new ReaderWriterLockSlim(LockRecursionPolicy.SupportsRecursion); |
||
145 | public bool ContainsKey(K1 key1, K2 key2, K3 key3, K4 key4, K5 key5) |
237 | |
|
146 | { |
238 | public V this[K1 key1, K2 key2, K3 key3, K4 key4, K5 key5, K6 key6] |
|
Line 147... | Line 239... | |||
147 | return ContainsKey(key1) && this[key1].ContainsKey(key2, key3, key4, key5); |
239 | { |
|
148 | } |
240 | get |
|
- | 241 | { |
||
149 | } |
242 | SyncRoot.EnterReadLock(); |
|
- | 243 | var v = ContainsKey(key1) ? this[key1][key2, key3, key4, key5, key6] : default(V); |
||
- | 244 | SyncRoot.ExitReadLock(); |
||
150 | |
245 | return v; |
|
151 | public class MultiKeyDictionary<K1, K2, K3, K4, K5, K6, V> : |
246 | } |
|
Line 152... | Line 247... | |||
152 | Dictionary<K1, MultiKeyDictionary<K2, K3, K4, K5, K6, V>> |
247 | set |
|
153 | { |
248 | { |
|
154 | public V this[K1 key1, K2 key2, K3 key3, K4 key4, K5 key5, K6 key6] |
249 | SyncRoot.EnterWriteLock(); |
|
- | 250 | if (!ContainsKey(key1)) |
||
- | 251 | this[key1] = new MultiKeyDictionary<K2, K3, K4, K5, K6, V>(); |
||
155 | { |
252 | this[key1][key2, key3, key4, key5, key6] = value; |
|
156 | get { return ContainsKey(key1) ? this[key1][key2, key3, key4, key5, key6] : default(V); } |
253 | SyncRoot.ExitWriteLock(); |
|
- | 254 | } |
||
- | 255 | } |
||
- | 256 | |
||
157 | set |
257 | public bool ContainsKey(K1 key1, K2 key2, K3 key3, K4 key4, K5 key5, K6 key6) |
|
- | 258 | { |
||
- | 259 | SyncRoot.EnterReadLock(); |
||
- | 260 | var c = ContainsKey(key1) && this[key1].ContainsKey(key2, key3, key4, key5, key6); |
||
158 | { |
261 | SyncRoot.ExitReadLock(); |
|
159 | if (!ContainsKey(key1)) |
262 | return c; |
|
- | 263 | } |
||
160 | this[key1] = new MultiKeyDictionary<K2, K3, K4, K5, K6, V>(); |
264 | } |
|
161 | this[key1][key2, key3, key4, key5, key6] = value; |
265 | |
|
162 | } |
266 | public class MultiKeyDictionary<K1, K2, K3, K4, K5, K6, K7, V> : |
|
- | 267 | Dictionary<K1, MultiKeyDictionary<K2, K3, K4, K5, K6, K7, V>> |
||
163 | } |
268 | { |
|
164 | |
269 | private readonly ReaderWriterLockSlim SyncRoot = new ReaderWriterLockSlim(LockRecursionPolicy.SupportsRecursion); |
|
Line 165... | Line 270... | |||
165 | public bool ContainsKey(K1 key1, K2 key2, K3 key3, K4 key4, K5 key5, K6 key6) |
270 | |
|
166 | { |
271 | public V this[K1 key1, K2 key2, K3 key3, K4 key4, K5 key5, K6 key6, K7 key7] |
|
- | 272 | { |
||
167 | return ContainsKey(key1) && this[key1].ContainsKey(key2, key3, key4, key5, key6); |
273 | get |
|
- | 274 | { |
||
- | 275 | SyncRoot.EnterReadLock(); |
||
168 | } |
276 | var v = ContainsKey(key1) ? this[key1][key2, key3, key4, key5, key6, key7] : default(V); |
|
169 | } |
277 | SyncRoot.ExitReadLock(); |
|
Line 170... | Line 278... | |||
170 | |
278 | return v; |
|
171 | public class MultiKeyDictionary<K1, K2, K3, K4, K5, K6, K7, V> : |
279 | } |
|
172 | Dictionary<K1, MultiKeyDictionary<K2, K3, K4, K5, K6, K7, V>> |
280 | set |
|
- | 281 | { |
||
- | 282 | SyncRoot.EnterWriteLock(); |
||
173 | { |
283 | if (!ContainsKey(key1)) |
|
174 | public V this[K1 key1, K2 key2, K3 key3, K4 key4, K5 key5, K6 key6, K7 key7] |
284 | this[key1] = new MultiKeyDictionary<K2, K3, K4, K5, K6, K7, V>(); |
|
- | 285 | this[key1][key2, key3, key4, key5, key6, key7] = value; |
||
- | 286 | SyncRoot.ExitWriteLock(); |
||
- | 287 | } |
||
175 | { |
288 | } |
|
- | 289 | |
||
- | 290 | public bool ContainsKey(K1 key1, K2 key2, K3 key3, K4 key4, K5 key5, K6 key6, K7 key7) |
||
- | 291 | { |
||
176 | get { return ContainsKey(key1) ? this[key1][key2, key3, key4, key5, key6, key7] : default(V); } |
292 | SyncRoot.EnterReadLock(); |
|
177 | set |
293 | var c = ContainsKey(key1) && this[key1].ContainsKey(key2, key3, key4, key5, key6, key7); |
|
- | 294 | SyncRoot.ExitReadLock(); |
||
178 | { |
295 | return c; |
|
179 | if (!ContainsKey(key1)) |
296 | } |
|
180 | this[key1] = new MultiKeyDictionary<K2, K3, K4, K5, K6, K7, V>(); |
297 | } |
|
- | 298 | |
||
181 | this[key1][key2, key3, key4, key5, key6, key7] = value; |
299 | public class MultiKeyDictionary<K1, K2, K3, K4, K5, K6, K7, K8, V> : |
|
182 | } |
300 | Dictionary<K1, MultiKeyDictionary<K2, K3, K4, K5, K6, K7, K8, V>> |
|
Line 183... | Line 301... | |||
183 | } |
301 | { |
|
184 | |
302 | private readonly ReaderWriterLockSlim SyncRoot = new ReaderWriterLockSlim(LockRecursionPolicy.SupportsRecursion); |
|
- | 303 | |
||
185 | public bool ContainsKey(K1 key1, K2 key2, K3 key3, K4 key4, K5 key5, K6 key6, K7 key7) |
304 | public V this[K1 key1, K2 key2, K3 key3, K4 key4, K5 key5, K6 key6, K7 key7, K8 key8] |
|
- | 305 | { |
||
- | 306 | get |
||
186 | { |
307 | { |
|
187 | return ContainsKey(key1) && this[key1].ContainsKey(key2, key3, key4, key5, key6, key7); |
308 | SyncRoot.EnterReadLock(); |
|
Line 188... | Line 309... | |||
188 | } |
309 | var v = ContainsKey(key1) ? this[key1][key2, key3, key4, key5, key6, key7, key8] : default(V); |
|
189 | } |
310 | SyncRoot.ExitReadLock(); |
|
190 | |
311 | return v; |
|
- | 312 | } |
||
- | 313 | set |
||
191 | public class MultiKeyDictionary<K1, K2, K3, K4, K5, K6, K7, K8, V> : |
314 | { |
|
192 | Dictionary<K1, MultiKeyDictionary<K2, K3, K4, K5, K6, K7, K8, V>> |
315 | SyncRoot.EnterWriteLock(); |
|
- | 316 | if (!ContainsKey(key1)) |
||
- | 317 | this[key1] = new MultiKeyDictionary<K2, K3, K4, K5, K6, K7, K8, V>(); |
||
- | 318 | this[key1][key2, key3, key4, key5, key6, key7, key8] = value; |
||
193 | { |
319 | SyncRoot.ExitWriteLock(); |
|
- | 320 | } |
||
- | 321 | } |
||
- | 322 | |
||
194 | public V this[K1 key1, K2 key2, K3 key3, K4 key4, K5 key5, K6 key6, K7 key7, K8 key8] |
323 | public bool ContainsKey(K1 key1, K2 key2, K3 key3, K4 key4, K5 key5, K6 key6, K7 key7, K8 key8) |
|
195 | { |
324 | { |
|
- | 325 | SyncRoot.EnterReadLock(); |
||
196 | get { return ContainsKey(key1) ? this[key1][key2, key3, key4, key5, key6, key7, key8] : default(V); } |
326 | var c = ContainsKey(key1) && this[key1].ContainsKey(key2, key3, key4, key5, key6, key7, key8); |
|
197 | set |
327 | SyncRoot.ExitReadLock(); |
|
198 | { |
328 | return c; |
|
- | 329 | } |
||
199 | if (!ContainsKey(key1)) |
330 | } |
|
200 | this[key1] = new MultiKeyDictionary<K2, K3, K4, K5, K6, K7, K8, V>(); |
331 | |
|
Line 201... | Line 332... | |||
201 | this[key1][key2, key3, key4, key5, key6, key7, key8] = value; |
332 | public class MultiKeyDictionary<K1, K2, K3, K4, K5, K6, K7, K8, K9, V> : |
|
202 | } |
333 | Dictionary<K1, MultiKeyDictionary<K2, K3, K4, K5, K6, K7, K8, K9, V>> |
|
- | 334 | { |
||
203 | } |
335 | private readonly ReaderWriterLockSlim SyncRoot = new ReaderWriterLockSlim(LockRecursionPolicy.SupportsRecursion); |
|
- | 336 | |
||
- | 337 | public V this[K1 key1, K2 key2, K3 key3, K4 key4, K5 key5, K6 key6, K7 key7, K8 key8, K9 key9] |
||
204 | |
338 | { |
|
205 | public bool ContainsKey(K1 key1, K2 key2, K3 key3, K4 key4, K5 key5, K6 key6, K7 key7, K8 key8) |
339 | get |
|
Line 206... | Line 340... | |||
206 | { |
340 | { |
|
207 | return ContainsKey(key1) && this[key1].ContainsKey(key2, key3, key4, key5, key6, key7, key8); |
341 | SyncRoot.EnterReadLock(); |
|
208 | } |
342 | var v = ContainsKey(key1) ? this[key1][key2, key3, key4, key5, key6, key7, key8, key9] : default(V); |
|
- | 343 | SyncRoot.ExitReadLock(); |
||
- | 344 | return v; |
||
209 | } |
345 | } |
|
210 | |
346 | set |
|
211 | public class MultiKeyDictionary<K1, K2, K3, K4, K5, K6, K7, K8, K9, V> : |
347 | { |
|
212 | Dictionary<K1, MultiKeyDictionary<K2, K3, K4, K5, K6, K7, K8, K9, V>> |
348 | SyncRoot.EnterWriteLock(); |
|
- | 349 | if (!ContainsKey(key1)) |
||
213 | { |
350 | this[key1] = new MultiKeyDictionary<K2, K3, K4, K5, K6, K7, K8, K9, V>(); |
|
- | 351 | this[key1][key2, key3, key4, key5, key6, key7, key8, key9] = value; |
||
- | 352 | SyncRoot.ExitWriteLock(); |
||
214 | public V this[K1 key1, K2 key2, K3 key3, K4 key4, K5 key5, K6 key6, K7 key7, K8 key8, K9 key9] |
353 | } |
|
215 | { |
354 | } |
|
216 | get { return ContainsKey(key1) ? this[key1][key2, key3, key4, key5, key6, key7, key8, key9] : default(V); } |
355 | |
|
- | 356 | public bool ContainsKey(K1 key1, K2 key2, K3 key3, K4 key4, K5 key5, K6 key6, K7 key7, K8 key8, K9 key9) |
||
217 | set |
357 | { |
|
218 | { |
358 | SyncRoot.EnterReadLock(); |
|
219 | if (!ContainsKey(key1)) |
359 | var c = ContainsKey(key1) && this[key1].ContainsKey(key2, key3, key4, key5, key6, key7, key8, key9); |
|
- | 360 | SyncRoot.ExitReadLock(); |
||
220 | this[key1] = new MultiKeyDictionary<K2, K3, K4, K5, K6, K7, K8, K9, V>(); |
361 | return c; |
|
221 | this[key1][key2, key3, key4, key5, key6, key7, key8, key9] = value; |
362 | } |
|
Line 222... | Line 363... | |||
222 | } |
363 | } |
|
223 | } |
364 | |
|
224 | |
365 | public class MultiKeyDictionary<K1, K2, K3, K4, K5, K6, K7, K8, K9, K10, V> : |
|
- | 366 | Dictionary<K1, MultiKeyDictionary<K2, K3, K4, K5, K6, K7, K8, K9, K10, V>> |
||
225 | public bool ContainsKey(K1 key1, K2 key2, K3 key3, K4 key4, K5 key5, K6 key6, K7 key7, K8 key8, K9 key9) |
367 | { |
|
226 | { |
368 | private readonly ReaderWriterLockSlim SyncRoot = new ReaderWriterLockSlim(LockRecursionPolicy.SupportsRecursion); |
|
- | 369 | |
||
- | 370 | public V this[K1 key1, K2 key2, K3 key3, K4 key4, K5 key5, K6 key6, K7 key7, K8 key8, K9 key9, K10 key10] |
||
227 | return ContainsKey(key1) && this[key1].ContainsKey(key2, key3, key4, key5, key6, key7, key8, key9); |
371 | { |
|
228 | } |
372 | get |
|
Line 229... | Line 373... | |||
229 | } |
373 | { |
|
230 | |
374 | SyncRoot.EnterReadLock(); |
|
231 | public class MultiKeyDictionary<K1, K2, K3, K4, K5, K6, K7, K8, K9, K10, V> : |
375 | var v = ContainsKey(key1) ? this[key1][key2, key3, key4, key5, key6, key7, key8, key9, key10] : default(V); |
|
- | 376 | SyncRoot.ExitReadLock(); |
||
- | 377 | return v; |
||
232 | Dictionary<K1, MultiKeyDictionary<K2, K3, K4, K5, K6, K7, K8, K9, K10, V>> |
378 | } |
|
233 | { |
379 | set |
|
234 | public V this[K1 key1, K2 key2, K3 key3, K4 key4, K5 key5, K6 key6, K7 key7, K8 key8, K9 key9, K10 key10] |
380 | { |
|
235 | { |
381 | SyncRoot.EnterWriteLock(); |
|
236 | get |
382 | if (!ContainsKey(key1)) |
|
- | 383 | this[key1] = new MultiKeyDictionary<K2, K3, K4, K5, K6, K7, K8, K9, K10, V>(); |
||
237 | { |
384 | this[key1][key2, key3, key4, key5, key6, key7, key8, key9, key10] = value; |
|
238 | return ContainsKey(key1) ? this[key1][key2, key3, key4, key5, key6, key7, key8, key9, key10] : default(V); |
385 | SyncRoot.ExitWriteLock(); |
|
239 | } |
386 | } |
|
- | 387 | } |
||
- | 388 | |
||
240 | set |
389 | public bool ContainsKey(K1 key1, K2 key2, K3 key3, K4 key4, K5 key5, K6 key6, K7 key7, K8 key8, K9 key9, |
|
241 | { |
390 | K10 key10) |
|
242 | if (!ContainsKey(key1)) |
391 | { |
|
- | 392 | SyncRoot.EnterReadLock(); |
||
243 | this[key1] = new MultiKeyDictionary<K2, K3, K4, K5, K6, K7, K8, K9, K10, V>(); |
393 | var c = ContainsKey(key1) && |
|
244 | this[key1][key2, key3, key4, key5, key6, key7, key8, key9, key10] = value; |
394 | this[key1].ContainsKey(key2, key3, key4, key5, key6, key7, key8, key9, key10); |
|
245 | } |
395 | SyncRoot.ExitReadLock(); |
|
- | 396 | return c; |
||
246 | } |
397 | } |
|
247 | |
398 | } |
|
Line 248... | Line 399... | |||
248 | public bool ContainsKey(K1 key1, K2 key2, K3 key3, K4 key4, K5 key5, K6 key6, K7 key7, K8 key8, K9 key9, |
399 | |
|
249 | K10 key10) |
400 | public class MultiKeyDictionary<K1, K2, K3, K4, K5, K6, K7, K8, K9, K10, K11, V> : |
|
250 | { |
401 | Dictionary<K1, MultiKeyDictionary<K2, K3, K4, K5, K6, K7, K8, K9, K10, K11, V>> |
|
- | 402 | { |
||
251 | return ContainsKey(key1) && |
403 | private readonly ReaderWriterLockSlim SyncRoot = new ReaderWriterLockSlim(LockRecursionPolicy.SupportsRecursion); |
|
252 | this[key1].ContainsKey(key2, key3, key4, key5, key6, key7, key8, key9, key10); |
404 | |
|
- | 405 | public V this[ |
||
- | 406 | K1 key1, K2 key2, K3 key3, K4 key4, K5 key5, K6 key6, K7 key7, K8 key8, K9 key9, K10 key10, K11 key11] |
||
253 | } |
407 | { |
|
254 | } |
408 | get |
|
255 | |
409 | { |