|
44 | 44 | /// <strong>ISubContent Performance Impact:</strong> |
45 | 45 | /// </para> |
46 | 46 | /// <para> |
47 | | -/// When structs marked with <see cref="UniqueAttribute"/> are used as keys in <see cref="ISubContent{TKey, TValue}"/> |
| 47 | +/// When structs marked with <see cref="UniqueAttribute"/> are used as keys in <see cref="ISubContent{TKey, TValue}"/> |
48 | 48 | /// implementations, the performance improvement is substantial: |
49 | 49 | /// </para> |
50 | 50 | /// <list type="bullet"> |
|
69 | 69 | /// // Readonly version (recommended for best performance) |
70 | 70 | /// [Unique] |
71 | 71 | /// public readonly partial record struct Material(string Name, int Durability, Color Color) : INamed; |
72 | | -/// |
| 72 | +/// |
73 | 73 | /// // Non-readonly version (still optimized with caching) |
74 | 74 | /// [Unique] |
75 | 75 | /// public partial record struct Material(string Name, int Durability, Color Color) : INamed; |
76 | | -/// |
| 76 | +/// |
77 | 77 | /// public partial class Materials : IContent<Material> |
78 | 78 | /// { |
79 | 79 | /// public static Material[] All = [ |
|
82 | 82 | /// new("Diamond", 500, Color.White) |
83 | 83 | /// ]; |
84 | 84 | /// } |
85 | | -/// |
| 85 | +/// |
86 | 86 | /// // Usage with ISubContent for high-performance lookups: |
87 | 87 | /// public class MaterialProperties : ISubContent<Material, PropertyData> |
88 | 88 | /// { |
|
92 | 92 | /// [Materials.Gold] = new PropertyData(/* ... */), |
93 | 93 | /// // Fast dictionary operations due to optimized Material equality/hashing |
94 | 94 | /// }; |
95 | | -/// |
| 95 | +/// |
96 | 96 | /// public PropertyData this[Material key] => ByKey[key]; // O(1) lookup |
97 | 97 | /// } |
98 | | -/// |
| 98 | +/// |
99 | 99 | /// // Generated code enables fast index-based equality: |
100 | 100 | /// var iron1 = materials.Iron; |
101 | 101 | /// var iron2 = materials.Get(MaterialsType.Iron); |
|
0 commit comments