Skip to content

Commit f41cf23

Browse files
format some stuff
1 parent 68599bd commit f41cf23

60 files changed

Lines changed: 496 additions & 329 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

ExtendedSystemObjects/BiMap.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,9 @@ public IEnumerator<KeyValuePair<T, T>> GetEnumerator()
8080
/// <summary>
8181
/// Initializes a new instance of the <see cref="T:ExtendedSystemObjects.BiMap`1" /> class.
8282
/// </summary>
83-
public BiMap() : this(0) { }
83+
public BiMap() : this(0)
84+
{
85+
}
8486

8587
/// <summary>
8688
/// Initializes a new instance of the <see cref="BiMap{T}"/> class.
@@ -161,7 +163,7 @@ public bool RemoveByLeft(T left)
161163
{
162164
lock (_lock)
163165
{
164-
if (!_forward.TryGetValue(left, out T? right)) return false;
166+
if (!_forward.TryGetValue(left, out var right)) return false;
165167

166168
_forward.Remove(left);
167169
_reverse.Remove(right);
@@ -193,4 +195,4 @@ public void Clear()
193195
}
194196
}
195197
}
196-
}
198+
}

ExtendedSystemObjects/CategorizedDictionary.cs

Lines changed: 82 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ namespace ExtendedSystemObjects
2727
/// <seealso cref="System.Collections.Generic.IEnumerable&lt;(TK Key, System.String Category, TV Value)&gt;" />
2828
[Serializable]
2929
public sealed class CategorizedDictionary<TK, TV> : IEnumerable<(TK Key, string Category, TV Value)>
30+
where TK : notnull
3031
{
3132
/// <summary>
3233
/// Internal storage mapping keys to (Category, Value) pairs.
@@ -71,8 +72,14 @@ public int Count
7172
get
7273
{
7374
_lock.EnterReadLock();
74-
try { return _data.Count; }
75-
finally { _lock.ExitReadLock(); }
75+
try
76+
{
77+
return _data.Count;
78+
}
79+
finally
80+
{
81+
_lock.ExitReadLock();
82+
}
7683
}
7784
}
7885

@@ -97,7 +104,10 @@ public TV this[TK key]
97104

98105
throw new KeyNotFoundException($"Key '{key}' not found.");
99106
}
100-
finally { _lock.ExitReadLock(); }
107+
finally
108+
{
109+
_lock.ExitReadLock();
110+
}
101111
}
102112
set
103113
{
@@ -113,7 +123,10 @@ public TV this[TK key]
113123
AddInternal(string.Empty, key, value);
114124
}
115125
}
116-
finally { _lock.ExitWriteLock(); }
126+
finally
127+
{
128+
_lock.ExitWriteLock();
129+
}
117130
}
118131
}
119132

@@ -133,8 +146,14 @@ public TV this[TK key]
133146
public void Add(string category, TK key, TV value)
134147
{
135148
_lock.EnterWriteLock();
136-
try { AddInternal(NormalizeCategory(category), key, value); }
137-
finally { _lock.ExitWriteLock(); }
149+
try
150+
{
151+
AddInternal(NormalizeCategory(category), key, value);
152+
}
153+
finally
154+
{
155+
_lock.ExitWriteLock();
156+
}
138157
}
139158

140159
/// <summary>
@@ -182,7 +201,10 @@ public bool Remove(TK key)
182201

183202
return true;
184203
}
185-
finally { _lock.ExitWriteLock(); }
204+
finally
205+
{
206+
_lock.ExitWriteLock();
207+
}
186208
}
187209

188210
/// <summary>
@@ -195,8 +217,14 @@ public bool Remove(TK key)
195217
public bool ContainsKey(TK key)
196218
{
197219
_lock.EnterReadLock();
198-
try { return _data.ContainsKey(key); }
199-
finally { _lock.ExitReadLock(); }
220+
try
221+
{
222+
return _data.ContainsKey(key);
223+
}
224+
finally
225+
{
226+
_lock.ExitReadLock();
227+
}
200228
}
201229

202230
/// <summary>
@@ -220,7 +248,10 @@ public bool TryGetValue(TK key, out TV value)
220248
value = default;
221249
return false;
222250
}
223-
finally { _lock.ExitReadLock(); }
251+
finally
252+
{
253+
_lock.ExitReadLock();
254+
}
224255
}
225256

226257
/// <summary>
@@ -244,7 +275,10 @@ public bool TryGetCategory(TK key, out string? category)
244275
category = null;
245276
return false;
246277
}
247-
finally { _lock.ExitReadLock(); }
278+
finally
279+
{
280+
_lock.ExitReadLock();
281+
}
248282
}
249283

250284
/// <summary>
@@ -263,7 +297,10 @@ public string GetCategory(TK key)
263297

264298
throw new KeyNotFoundException();
265299
}
266-
finally { _lock.ExitReadLock(); }
300+
finally
301+
{
302+
_lock.ExitReadLock();
303+
}
267304
}
268305

269306
/// <summary>
@@ -307,7 +344,10 @@ public bool SetCategory(TK key, string newCategory)
307344

308345
return true;
309346
}
310-
finally { _lock.ExitWriteLock(); }
347+
finally
348+
{
349+
_lock.ExitWriteLock();
350+
}
311351
}
312352

313353
/// <summary>
@@ -322,7 +362,10 @@ public IEnumerable<string> GetCategories()
322362
// Fix: Must snapshot keys inside the lock to allow safe iteration outside
323363
return new List<string>(_categories.Keys);
324364
}
325-
finally { _lock.ExitReadLock(); }
365+
finally
366+
{
367+
_lock.ExitReadLock();
368+
}
326369
}
327370

328371
/// <summary>
@@ -344,7 +387,10 @@ public IEnumerable<TK> GetKeys(string category)
344387

345388
return Array.Empty<TK>();
346389
}
347-
finally { _lock.ExitReadLock(); }
390+
finally
391+
{
392+
_lock.ExitReadLock();
393+
}
348394
}
349395

350396
/// <summary>
@@ -361,7 +407,10 @@ public IEnumerable<TK> GetKeys()
361407
// Fix: Must snapshot keys inside the lock
362408
return new List<TK>(_data.Keys);
363409
}
364-
finally { _lock.ExitReadLock(); }
410+
finally
411+
{
412+
_lock.ExitReadLock();
413+
}
365414
}
366415

367416
/// <summary>
@@ -379,7 +428,10 @@ public IEnumerable<TK> GetKeys()
379428

380429
return null;
381430
}
382-
finally { _lock.ExitReadLock(); }
431+
finally
432+
{
433+
_lock.ExitReadLock();
434+
}
383435
}
384436

385437

@@ -402,7 +454,10 @@ public Dictionary<TK, TV> GetCategory(string category)
402454
foreach (var key in keys) dict[key] = _data[key].Value;
403455
return dict;
404456
}
405-
finally { _lock.ExitReadLock(); }
457+
finally
458+
{
459+
_lock.ExitReadLock();
460+
}
406461
}
407462

408463
/// <summary>
@@ -416,7 +471,10 @@ public void Clear()
416471
_data.Clear();
417472
_categories.Clear();
418473
}
419-
finally { _lock.ExitWriteLock(); }
474+
finally
475+
{
476+
_lock.ExitWriteLock();
477+
}
420478
}
421479

422480
/// <summary>
@@ -436,7 +494,10 @@ public void Clear()
436494
foreach (var kvp in _data)
437495
snapshot.Add((kvp.Key, kvp.Value.Category, kvp.Value.Value));
438496
}
439-
finally { _lock.ExitReadLock(); }
497+
finally
498+
{
499+
_lock.ExitReadLock();
500+
}
440501

441502
// Iterate outside the lock to avoid deadlocks or contention
442503
foreach (var item in snapshot) yield return item;
@@ -450,4 +511,4 @@ public void Clear()
450511
/// </returns>
451512
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
452513
}
453-
}
514+
}

ExtendedSystemObjects/ExtendedDictionary.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ public static Dictionary<TKey, TValue> GetDictionaryByValues<TKey, TValue>(this
296296
/// <typeparam name="TValue">Internal Value</typeparam>
297297
/// <param name="dic">Internal Target Dictionary</param>
298298
/// <returns>Clone of the Input Dictionary</returns>
299-
public static Dictionary<TKey, TValue>? Clone<TKey, TValue>(this IDictionary<TKey, TValue> dic)
299+
public static Dictionary<TKey, TValue>? Clone<TKey, TValue>(this IDictionary<TKey, TValue>? dic)
300300
where TKey : notnull
301301
{
302302
return dic?.ToDictionary(dctClone => dctClone.Key, dctClone => dctClone.Value);
@@ -365,4 +365,4 @@ public static List<TValue> ToListId<TId, TValue>(this Dictionary<TId, TValue> di
365365
return lst;
366366
}
367367
}
368-
}
368+
}

ExtendedSystemObjects/ExtendedDouble.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,4 @@ public static bool IsEqualTo(this double first, double second)
4545
return Math.Abs(first - second) < double.Epsilon;
4646
}
4747
}
48-
}
48+
}

ExtendedSystemObjects/ExtendedInt.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,4 +90,4 @@ public static int RoundToInt(this float value)
9090
return (int)(value + 0.5f); // round up for positive values
9191
}
9292
}
93-
}
93+
}

ExtendedSystemObjects/ExtendedList.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,10 @@ public static bool AddDistinct<TValue>(this List<TValue> lst, TValue item)
8080
/// <param name="item">The item.</param>
8181
public static void RemoveFast<TValue>(this List<TValue> list, TValue item)
8282
{
83-
int index = list.IndexOf(item);
83+
var index = list.IndexOf(item);
8484
if (index < 0) return; // Item not found
8585

86-
int lastIndex = list.Count - 1;
86+
var lastIndex = list.Count - 1;
8787

8888
// Move the last element into the slot of the element to remove
8989
list[index] = list[lastIndex];
@@ -103,7 +103,7 @@ public static void RemoveAtFast<TValue>(this List<TValue> list, int index)
103103
{
104104
if (index < 0 || index >= list.Count) return;
105105

106-
int lastIndex = list.Count - 1;
106+
var lastIndex = list.Count - 1;
107107

108108
// Move the last element into the slot of the element to remove
109109
list[index] = list[lastIndex];
@@ -118,7 +118,7 @@ public static void RemoveAtFast<TValue>(this List<TValue> list, int index)
118118
/// <typeparam name="TValue">The type of the value.</typeparam>
119119
/// <param name="lst">The List.</param>
120120
/// <returns>A Dictionary from a list with int as the key</returns>
121-
public static Dictionary<int, TValue>? ToDictionary<TValue>(this IEnumerable<TValue> lst)
121+
public static Dictionary<int, TValue>? ToDictionary<TValue>(this IEnumerable<TValue>? lst)
122122
{
123123
var index = 0;
124124
return lst?.ToDictionary(_ => index++);
@@ -349,4 +349,4 @@ public static Dictionary<TId, TValue> ToDictionaryId<TValue, TId>(this IEnumerab
349349
return dct;
350350
}
351351
}
352-
}
352+
}

ExtendedSystemObjects/FastLinq.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,4 +269,4 @@ public static int CountFast<T>(this Span<T> span)
269269
return span.Length;
270270
}
271271
}
272-
}
272+
}

ExtendedSystemObjects/Helper/EntryGeneric.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,4 @@ public struct EntryGeneric<TValue> where TValue : unmanaged
3535
/// </summary>
3636
public TValue value;
3737
}
38-
}
38+
}

ExtendedSystemObjects/Helper/EntryGenericEnumerator.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ public void Reset()
9898
/// <summary>
9999
/// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
100100
/// </summary>
101-
public readonly void Dispose() { }
101+
public readonly void Dispose()
102+
{
103+
}
102104
}
103-
}
105+
}

ExtendedSystemObjects/Helper/EnumerableCompare.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,4 @@ public enum EnumerableCompare
2828
/// </summary>
2929
AllEqual = 2
3030
}
31-
}
31+
}

0 commit comments

Comments
 (0)