How IdentifiedArray works and its design constraints
mainIdentifiedArray is a lightweight wrapper around Apple's OrderedDictionary. It is specifically designed to maintain the invariants required for a collection of identifiable elements.
Design Principles
- Invariant Protection: Unlike a raw
OrderedDictionary<ID, Element>,IdentifiedArrayensures that an element's identifier always matches its key and prevents duplicate IDs. - No Hashable Requirement: Unlike
OrderedSet,IdentifiedArraydoes not require theElementto conform toHashable. - Flexible Identification: Elements do not strictly need to conform to
Identifiable; you can construct anIdentifiedArrayby providing anidkey path.
Performance
IdentifiedArray is designed to match the performance characteristics of OrderedDictionary.