Swift Threads
Swift Threads
- Subject: Swift Threads
- From: "Gerriet M. Denkmann" <email@hidden>
- Date: Sat, 23 Aug 2014 14:46:18 +0700
I searched the Swift book for "thread" and found nothing.
A quicksort algorithm works like:
quicksort(array)
{
partition(array)
quicksort( left side)
quicksort( right side)
}
On Obj-C I just did:
quicksort(array)
{
partition(array)
dispatch_apply( 2, queue, ^void(size_t idx)
{
quicksort( left or right side depending on idx )
}
}
Works fine and is twice as fast.
But how to do this in Swift?
Just doing the same as in Obj-C does not work (nor is it expected, as there is no documented thread-safeness of Swift arrays).
One other thing:
Trying to compare Apples to Apples I sorted an array of strings (using localizedCompare:) with Swift and Obj-C.
Swift (beta 6) is about 3 times slower (more if there are many identical strings in the array).
Gerriet.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden