55// Created by Marquis Kurt on 18-06-2025.
66//
77
8+ import Bedrock
89import Foundation
910import MCMap
1011
@@ -26,74 +27,4 @@ import MCMap
2627/// }
2728/// }
2829/// ```
29- struct IndexedPinCollection {
30- fileprivate typealias InternalContainer = [ CartographyMapPin ]
31- /// A structure representing an element in the collection.
32- struct Element : Identifiable , Equatable , Hashable {
33- /// A unique identifier for the element.
34- var id : Int { index }
35-
36- /// The index where the pin can be found in the source list.
37- var index : Int
38-
39- /// The contents of the pin.
40- var content : CartographyMapPin
41- }
42-
43- private var elements : [ CartographyMapPin ]
44-
45- /// Create a collection from an existing array of pins.
46- init ( _ elements: [ CartographyMapPin ] ) {
47- self . elements = elements
48- }
49- }
50-
51- extension IndexedPinCollection : Codable {
52- func encode( to encoder: any Encoder ) throws {
53- var container = encoder. singleValueContainer ( )
54- try container. encode ( elements)
55- }
56-
57- init ( from decoder: any Decoder ) throws {
58- let container = try decoder. singleValueContainer ( )
59- self . elements = try container. decode ( InternalContainer . self)
60- }
61- }
62-
63- extension IndexedPinCollection : Equatable { }
64-
65- extension IndexedPinCollection : Hashable {
66- func hash( into hasher: inout Hasher ) {
67- hasher. combine ( elements)
68- }
69- }
70-
71- extension IndexedPinCollection : ExpressibleByArrayLiteral {
72- typealias ArrayLiteralElement = CartographyMapPin
73-
74- init ( arrayLiteral elements: CartographyMapPin ... ) {
75- self . init ( elements)
76- }
77- }
78-
79- extension IndexedPinCollection : Collection {
80- typealias Index = [ CartographyMapPin ] . Index
81-
82- var startIndex : Array < CartographyMapPin > . Index {
83- elements. startIndex
84- }
85-
86- var endIndex : Array < CartographyMapPin > . Index {
87- elements. endIndex
88- }
89-
90- subscript( position: Array < CartographyMapPin > . Index ) -> Element {
91- return Element ( index: Int ( position) , content: elements [ position] )
92- }
93-
94- func index( after index: Array < CartographyMapPin > . Index ) -> Array < CartographyMapPin > . Index {
95- elements. index ( after: index)
96- }
97- }
98-
99- extension IndexedPinCollection : RandomAccessCollection { }
30+ typealias IndexedPinCollection = IndexedCollection < CartographyMapPin >
0 commit comments