Handle<T>
Struct · namespace System · Since 0.42
struct Handle<T> : IEquatable<Handle<T>>, IHashableA handle to an element of a SlotMap: where it is (Slot) and which occupant of that place it means
(Generation). Handles are plain values (two ints, no reference count): they can be copied, kept in structs, used as
Dictionary keys and passed to threads, and they never keep an element alive or form a cycle.
A handle stays valid until its element is removed; after that it is stale and the map rejects it, also when the
place has a new occupant. The zero value (new(), a field without a value) is never valid: a “no element” handle.
The type argument keeps handles of different maps apart: a Handle<Unit> does not fit a SlotMap<Item>.
Fields
Section titled “Fields”| Name | Description |
|---|---|
Slot |
The place in the map. |
Generation |
The occupant of that place (odd numbers, from 1; 0 is never valid). |
int SlotThe place in the map.
Generation
Section titled “Generation”int GenerationThe occupant of that place (odd numbers, from 1; 0 is never valid).
Methods
Section titled “Methods”| Name | Description |
|---|---|
IsNone |
Whether this is the zero value, which refers to no element. |
Equals |
Whether both refer to the same place and occupant. |
GetHashCode |
A hash code of the place and the occupant. |
ToString |
The handle as text: #3.1 (place 3, occupant 1). |
IsNone
Section titled “IsNone”bool IsNone()Whether this is the zero value, which refers to no element.
Equals
Section titled “Equals”bool Equals(Handle<T> other)Whether both refer to the same place and occupant.
GetHashCode
Section titled “GetHashCode”int GetHashCode()A hash code of the place and the occupant.
ToString
Section titled “ToString”string ToString()The handle as text: #3.1 (place 3, occupant 1).