| | | 1 | | using MemoryPack; |
| | | 2 | | using System; |
| | | 3 | | using System.Collections.Generic; |
| | | 4 | | using System.Text.Json.Serialization; |
| | | 5 | | |
| | | 6 | | namespace SwiftCollections; |
| | | 7 | | |
| | | 8 | | /// <summary> |
| | | 9 | | /// Represents an immutable snapshot of the key-value pairs contained in a dictionary at a specific point in time. |
| | | 10 | | /// </summary> |
| | | 11 | | /// <remarks> |
| | | 12 | | /// This struct is typically used to serialize or transfer the state of a dictionary. |
| | | 13 | | /// The contents are read-only and reflect the state of the dictionary when the snapshot was taken. |
| | | 14 | | /// </remarks> |
| | | 15 | | /// <typeparam name="TKey">The type of keys in the dictionary.</typeparam> |
| | | 16 | | /// <typeparam name="TValue">The type of values in the dictionary.</typeparam> |
| | | 17 | | [Serializable] |
| | | 18 | | [MemoryPackable] |
| | | 19 | | public readonly partial struct SwiftDictionaryState<TKey, TValue> |
| | | 20 | | { |
| | | 21 | | /// <summary> |
| | | 22 | | /// Gets the collection of key/value pairs contained in the object. |
| | | 23 | | /// </summary> |
| | | 24 | | [JsonInclude] |
| | | 25 | | [MemoryPackInclude] |
| | | 26 | | public readonly KeyValuePair<TKey, TValue>[] Items; |
| | | 27 | | |
| | | 28 | | /// <summary> |
| | | 29 | | /// Initializes a new instance of the SwiftDictionaryState class with the specified key-value pairs. |
| | | 30 | | /// </summary> |
| | | 31 | | /// <remarks> |
| | | 32 | | /// This constructor is typically used during deserialization to restore the state of the dictionary from a serializ |
| | | 33 | | /// </remarks> |
| | | 34 | | /// <param name="items">An array of key-value pairs to initialize the dictionary state. Cannot be null.</param> |
| | | 35 | | [JsonConstructor] |
| | | 36 | | [MemoryPackConstructor] |
| | | 37 | | public SwiftDictionaryState(KeyValuePair<TKey, TValue>[] items) |
| | | 38 | | { |
| | 31 | 39 | | Items = items; |
| | 31 | 40 | | } |
| | | 41 | | } |