Class SeqPair<T>
Represents a sequence pair containing previous and current values. Used to track sequential state changes of a value.
public class SeqPair<T> : IEquatable<SeqPair<T>>, IWriteBin
Type Parameters
TThe type of values stored in the sequence pair
- Inheritance
-
SeqPair<T>
- Implements
-
IEquatable<SeqPair<T>>
- Inherited Members
- Extension Methods
Constructors
SeqPair()
Initializes a new instance of the SeqPair<T> class with default values for previous and current elements.
public SeqPair()
SeqPair(BinaryReader, Func<BinaryReader, T>)
Initializes a new instance of the SeqPair<T> class by deserializing from binary data.
public SeqPair(BinaryReader reader, Func<BinaryReader, T> Generator)
Parameters
readerBinaryReaderThe binary reader to read data from
GeneratorFunc<BinaryReader, T>A function that creates objects of type T from binary data
Remarks
A cleared bit means the member was not written, and that member is left at
default(T). Files written while T was still a
reference type can carry cleared bits, so the reader keeps honouring them
however the writer behaves today — that is what keeps old files loadable.
SeqPair(T, T)
Initializes a new instance of the SeqPair<T> class with specified previous and current values.
public SeqPair(T pre, T cur)
Parameters
preTThe previous value in the sequence
curTThe current value in the sequence
Fields
cur
Gets or sets the current value in the sequence.
public T cur
Field Value
- T
pre
Gets or sets the previous value in the sequence.
public T pre
Field Value
- T
Methods
Equals(SeqPair<T>)
Indicates whether the current object is equal to another object of the same type.
public bool Equals(SeqPair<T> other)
Parameters
otherSeqPair<T>An object to compare with this object.
Returns
Equals(object)
Determines whether the specified object is equal to the current object.
public override bool Equals(object obj)
Parameters
objobjectThe object to compare with the current object.
Returns
GetHashCode()
Serves as the default hash function.
public override int GetHashCode()
Returns
- int
A hash code for the current object.
ToString()
Returns a string that represents the current object.
public override string ToString()
Returns
- string
A string that represents the current object.
WriteBin(BinaryWriter)
Writes the object's data to a binary stream.
public void WriteBin(BinaryWriter writer)
Parameters
writerBinaryWriterThe binary writer to write to
Remarks
The mask is derived from the same two references the payload is written
through, so a bit can never claim a member the bytes do not carry. The
as answers both questions at once: it is null for an absent
reference member, and it boxes a value member, which has no absent state.
A value-type T therefore always writes both bits —
default(T) is a value, not an absence — which is what
SeqPair<vec3d_t> becomes once vec3d_t is a struct.
Taking the mask from the reference rather than from pre == null also
closes two holes. On an unconstrained type parameter == null is
constant false for a value type with no diagnostic at all, not even CS8073. For a value
type the cleared bit therefore reads back as default(T) -- the zero matrix for
mat4d_t, not the identity and not an absence; every producer in the
workspace fills both members, so a stream written by one never carries a cleared bit.
And a T that does not implement IWriteBin
used to set the bit and then write nothing, leaving every following record
in the stream misaligned; it is now recorded as absent, which loses that
member but keeps the stream readable.