<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div><span></span></div><div><meta http-equiv="Content-Type" content="text/html charset=utf-8">Hello,<br class=""><div><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""><br class=""></div><div class="">in the past there have been a few requests for an OrderedSet implementation in Swift. In the proposal <a href="https://github.com/apple/swift-evolution/blob/master/proposals/0069-swift-mutability-for-foundation.md" class="">https://github.com/apple/swift-evolution/blob/master/proposals/0069-swift-mutability-for-foundation.md</a> was mentioned that the OrderedSet will be considered for the feature.</div><div class=""><br class=""></div><div class="">However, since then there were a few discussions on OrderedSet but it doesn’t get much attention and there wasn’t any comment about it from the swift team.</div><div class=""><br class=""></div><div class="">I want to bring up some points, why an OrderedSet is needed in the base library.</div><div class=""><br class=""></div><div class="">1. CoreData is probably the most obvious place where people would use an ordered set. Especially when working with large amounts of data, presorting can save a lot of time and battery life. If a bridgeable ordered set was part of the standard library we could use a ordered set in swift without having to use the NSOrderedSet from objective c. Which would be pretty nice in my opinion. Even when using a NSOrderedSet we couldn’t have a generic version of it.</div><div class=""><br class=""></div><div class="">2. A shared datamodel between App and Server. One main advantage of having web servers written in Swift is that we can share code between the server and the app. For servers performance does matter a lot, since they are usually working with much more data than apps. Databases are represented as sets and fetching sorted data from the database can be represented as an ordered set. However, since we don’t have ordered sets we have to choose either a normal set or an array. Sets don’t have an order and arrays can contain the same object multiple times, which makes them both a less suitable choice.</div><div class=""><br class=""></div><div class="">3. Swift has the potential to be used for education. There is a lot of support, for example the playground app on iPad. When it comes to the theory behind data structures and algorithms or to the theory of computation a defined order plays an important role.</div><div class=""><br class=""></div><div class="">The biggest issue is that we always have to copy data from a set into an array to have it in a sorted order with losing the safety of uniqueness. Which is not suitable for a safe and performance oriented programming language at all.</div><div class=""><br class=""></div><div class="">Last but not least, it fits in the goals of Swift 4 stage 2 and an ordered set can be found in other popular programming languages, too.</div><div class=""><br class=""></div><div class="">What do you think?</div><div class=""><br class=""></div><div class="">Best regards,</div><div class=""><br class=""></div><div class="">Maik</div></div></div></div></div></div></div><br class=""></div></body></html>