Add is function.

This commit is contained in:
2023-01-16 20:46:57 +08:00
parent 1003a0e199
commit 09e917dbe8
2 changed files with 21 additions and 1 deletions

View File

@@ -4,7 +4,7 @@ namespace Cryville.Common.Pdt {
/// <summary>
/// Span on the memory of a <see cref="PdtEvaluatorBase" />.
/// </summary>
public unsafe struct PdtVariableMemory {
public unsafe struct PdtVariableMemory : IEquatable<PdtVariableMemory> {
readonly byte* _ptr;
/// <summary>
/// The length of the span.
@@ -46,6 +46,14 @@ namespace Cryville.Common.Pdt {
for (int i = 0; i < length; i++)
dest[destOffset + i] = _ptr[i];
}
/// <inheritdoc />
public bool Equals(PdtVariableMemory obj) {
if (Type != obj.Type || Length != obj.Length) return false;
for (int i = 0; i < Length; i++) {
if (*(_ptr + i) != *(obj._ptr + i)) return false;
}
return true;
}
/// <summary>
/// Gets the memory of the span as a number.
/// </summary>