Introduce OrderedSet type


(Nicholas Maccharoli) #1

Hello Swift Community,

Recently I have noticed that there is a Set type but no OrderedSet type yet.
If I want a set that preserves the original order I have to go with
NSOrderedSet
but I think it would be nice to have a native implementation in the
standard library.

What are your thoughts on this?

Thanks!

- Nick


(Rod Brown) #2

I believe this would fall in line with by Proposal SE-0069: Mutability and Foundation Value Types:

https://github.com/apple/swift-evolution/blob/master/proposals/0069-swift-mutability-for-foundation.md

I notice there is no OrderedSet in this proposal. I find it odd that it doesn’t yet include it.

- Rod

···

On 4 May 2016, at 1:24 PM, Nicholas Maccharoli via swift-evolution <swift-evolution@swift.org> wrote:

Hello Swift Community,

Recently I have noticed that there is a Set type but no OrderedSet type yet.
If I want a set that preserves the original order I have to go with NSOrderedSet
but I think it would be nice to have a native implementation in the standard library.

What are your thoughts on this?

Thanks!

- Nick

_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution


(Austin Zheng) #3

I think it would be nice to have a native Swift OrderedSet type, as well as
a priority queue and support for collections holding weak references. This
set of changes would go a long way towards providing Swift with a set of
universally available, widely applicable data structures similar to those
offered by other language's standard libraries.

My personal opinion is that these data structures are probably important
enough to be part of the stdlib itself, without forcing projects to take in
Foundation as a dependency. They can be designed in such a way so that they
bridge to the NS*-equivalents, just as Array, Dictionary, and Set do today.

Is anyone planning on writing up a proposal? If not I can take a crack at
it.

Austin

···

On Tue, May 3, 2016 at 8:50 PM, Rod Brown via swift-evolution < swift-evolution@swift.org> wrote:

I believe this would fall in line with by Proposal SE-0069: Mutability and
Foundation Value Types:

https://github.com/apple/swift-evolution/blob/master/proposals/0069-swift-mutability-for-foundation.md

I notice there is no OrderedSet in this proposal. I find it odd that it
doesn’t yet include it.

- Rod

On 4 May 2016, at 1:24 PM, Nicholas Maccharoli via swift-evolution < > swift-evolution@swift.org> wrote:

Hello Swift Community,

Recently I have noticed that there is a Set type but no OrderedSet type
yet.
If I want a set that preserves the original order I have to go with
NSOrderedSet
but I think it would be nice to have a native implementation in the
standard library.

What are your thoughts on this?

Thanks!

- Nick

_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution

_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution


(Rod Brown) #4

Tony,

With regard to this proposal, is there any reason that this proposal did not include an OrderedSet value type? I suspect perhaps this is an oversight?

- Rod

···

On 4 May 2016, at 1:50 PM, Rod Brown via swift-evolution <swift-evolution@swift.org> wrote:

I believe this would fall in line with by Proposal SE-0069: Mutability and Foundation Value Types:

https://github.com/apple/swift-evolution/blob/master/proposals/0069-swift-mutability-for-foundation.md

I notice there is no OrderedSet in this proposal. I find it odd that it doesn’t yet include it.

- Rod

On 4 May 2016, at 1:24 PM, Nicholas Maccharoli via swift-evolution <swift-evolution@swift.org <mailto:swift-evolution@swift.org>> wrote:

Hello Swift Community,

Recently I have noticed that there is a Set type but no OrderedSet type yet.
If I want a set that preserves the original order I have to go with NSOrderedSet
but I think it would be nice to have a native implementation in the standard library.

What are your thoughts on this?

Thanks!

- Nick

_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org <mailto:swift-evolution@swift.org>
https://lists.swift.org/mailman/listinfo/swift-evolution

_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution


(Tony Parker) #5

Hi Rod,

Tony,

With regard to this proposal, is there any reason that this proposal did not include an OrderedSet value type? I suspect perhaps this is an oversight?

- Rod

We considered it, but did not include it in this proposal for scoping reasons. It’s not quite as straightforward to bridge as the other types because it really should allow containment of “Any”, but NSOrderedSet would instead require “AnyObject.” This is fixable but involves a large amount of engineering work.

- Tony

···

On May 4, 2016, at 4:59 AM, Rod Brown <rodney.brown6@icloud.com> wrote:

On 4 May 2016, at 1:50 PM, Rod Brown via swift-evolution <swift-evolution@swift.org <mailto:swift-evolution@swift.org>> wrote:

I believe this would fall in line with by Proposal SE-0069: Mutability and Foundation Value Types:

https://github.com/apple/swift-evolution/blob/master/proposals/0069-swift-mutability-for-foundation.md

I notice there is no OrderedSet in this proposal. I find it odd that it doesn’t yet include it.

- Rod

On 4 May 2016, at 1:24 PM, Nicholas Maccharoli via swift-evolution <swift-evolution@swift.org <mailto:swift-evolution@swift.org>> wrote:

Hello Swift Community,

Recently I have noticed that there is a Set type but no OrderedSet type yet.
If I want a set that preserves the original order I have to go with NSOrderedSet
but I think it would be nice to have a native implementation in the standard library.

What are your thoughts on this?

Thanks!

- Nick

_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org <mailto:swift-evolution@swift.org>
https://lists.swift.org/mailman/listinfo/swift-evolution

_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org <mailto:swift-evolution@swift.org>
https://lists.swift.org/mailman/listinfo/swift-evolution