• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Swift Threads
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Prev by Date: Re: iOS database within sandbox
  • Next by Date: Re: buggy sequence: miniaturize/close/makeKeyAndOrderFront
  • Previous by thread: Re: Bad EXC_BAD_INSTRUCTION on drawRect call in Swift
  • Next by thread: Re: Swift Threads
  • Index(es):
    • Date
    • Thread