Ordered map in Swift

前端 未结 12 1236
忘掉有多难
忘掉有多难 2020-11-28 09:24

Is there any built-in way to create an ordered map in Swift 2? Arrays [T] are sorted by the order that objects are appended to it, but dictionaries

12条回答
  •  广开言路
    2020-11-28 10:22

    I know i am l8 to the party but did you look into NSMutableOrderedSet ?

    https://developer.apple.com/reference/foundation/nsorderedset

    You can use ordered sets as an alternative to arrays when the order of elements is important and performance in testing whether an object is contained in the set is a consideration—testing for membership of an array is slower than testing for membership of a set.

提交回复
热议问题