Struct Identifier
- Namespace
- LfrlAnvil.Identifiers
- Assembly
- LfrlAnvil.Identifiers.dll
A lightweight object that can be used as a unique ID.
public readonly struct Identifier : IEquatable<Identifier>, IComparable<Identifier>, IComparable
- Implements
- Inherited Members
Constructors
Identifier(ulong)
Creates a new Identifier instance.
public Identifier(ulong value)
Parameters
value
ulongUnderlying value.
Identifier(ulong, ushort)
Creates a new Identifier instance.
public Identifier(ulong high, ushort low)
Parameters
Fields
MaxHighValue
Specifies maximum possible High value.
public const ulong MaxHighValue = 281474976710655
Field Value
Value
Underlying value.
public readonly ulong Value
Field Value
Properties
High
Specifies the 48-bit high value of this instance. If this Identifier has been created by an IdentifierGenerator then this value represents a Timestamp at which it has been created. That Timestamp can be extracted by invoking the GetTimestamp(Identifier) method.
public ulong High { get; }
Property Value
Low
Specifies the low value of this instance. If this Identifier has been created by an IdentifierGenerator then this value represents a unique sequential number with which it has been created at a given time slice represented by its High value.
public ushort Low { get; }
Property Value
Methods
CompareTo(Identifier)
Compares the current instance with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other object.
[Pure]
public int CompareTo(Identifier other)
Parameters
other
IdentifierAn object to compare with this instance.
Returns
- int
A value that indicates the relative order of the objects being compared. The return value has these meanings:
Value Meaning Less than zero This instance precedes other
in the sort order.Zero This instance occurs in the same position in the sort order as other
.Greater than zero This instance follows other
in the sort order.
CompareTo(object?)
Compares the current instance with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other object.
[Pure]
public int CompareTo(object? obj)
Parameters
obj
objectAn object to compare with this instance.
Returns
- int
A value that indicates the relative order of the objects being compared. The return value has these meanings:
Value Meaning Less than zero This instance precedes obj
in the sort order.Zero This instance occurs in the same position in the sort order as obj
.Greater than zero This instance follows obj
in the sort order.
Exceptions
- ArgumentException
obj
is not the same type as this instance.
Equals(Identifier)
Indicates whether the current object is equal to another object of the same type.
[Pure]
public bool Equals(Identifier other)
Parameters
other
IdentifierAn object to compare with this object.
Returns
Equals(object?)
Indicates whether this instance and a specified object are equal.
[Pure]
public override bool Equals(object? obj)
Parameters
obj
objectThe object to compare with the current instance.
Returns
- bool
true if
obj
and this instance are the same type and represent the same value; otherwise, false.
GetHashCode()
Returns the hash code for this instance.
[Pure]
public override int GetHashCode()
Returns
- int
A 32-bit signed integer that is the hash code for this instance.
ToString()
Returns a string representation of this Identifier instance.
[Pure]
public override string ToString()
Returns
- string
String representation.
Operators
operator ==(Identifier, Identifier)
Checks if a
is equal to b
.
[Pure]
public static bool operator ==(Identifier a, Identifier b)
Parameters
a
IdentifierFirst operand.
b
IdentifierSecond operand.
Returns
- bool
true when operands are equal, otherwise false.
explicit operator ulong(Identifier)
[Pure]
public static explicit operator ulong(Identifier id)
Parameters
id
IdentifierObject to convert.
Returns
operator >(Identifier, Identifier)
Checks if a
is greater than b
.
[Pure]
public static bool operator >(Identifier a, Identifier b)
Parameters
a
IdentifierFirst operand.
b
IdentifierSecond operand.
Returns
- bool
true when
a
is greater thanb
, otherwise false.
operator >=(Identifier, Identifier)
Checks if a
is greater than or equal to b
.
[Pure]
public static bool operator >=(Identifier a, Identifier b)
Parameters
a
IdentifierFirst operand.
b
IdentifierSecond operand.
Returns
- bool
true when
a
is greater than or equal tob
, otherwise false.
operator !=(Identifier, Identifier)
Checks if a
is not equal to b
.
[Pure]
public static bool operator !=(Identifier a, Identifier b)
Parameters
a
IdentifierFirst operand.
b
IdentifierSecond operand.
Returns
- bool
true when operands are not equal, otherwise false.
operator <(Identifier, Identifier)
Checks if a
is less than b
.
[Pure]
public static bool operator <(Identifier a, Identifier b)
Parameters
a
IdentifierFirst operand.
b
IdentifierSecond operand.
Returns
- bool
true when
a
is less thanb
, otherwise false.
operator <=(Identifier, Identifier)
Checks if a
is less than or equal to b
.
[Pure]
public static bool operator <=(Identifier a, Identifier b)
Parameters
a
IdentifierFirst operand.
b
IdentifierSecond operand.
Returns
- bool
true when
a
is less than or equal tob
, otherwise false.