From 7b958d7464e67fd77596007e37bf1f741b4d920c Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Sun, 9 Apr 2023 23:04:09 +0300 Subject: Update content for html --- .../2023-04-09-algorithms-and-data-structures-in-golang-part-1.html | 2 ++ gemfeed/atom.xml | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) (limited to 'gemfeed') diff --git a/gemfeed/2023-04-09-algorithms-and-data-structures-in-golang-part-1.html b/gemfeed/2023-04-09-algorithms-and-data-structures-in-golang-part-1.html index 2984a1e0..e616767d 100644 --- a/gemfeed/2023-04-09-algorithms-and-data-structures-in-golang-part-1.html +++ b/gemfeed/2023-04-09-algorithms-and-data-structures-in-golang-part-1.html @@ -220,6 +220,8 @@ http://www.gnu.org/software/src-highlite --> }
+This Go code implements the sleep sort algorithm using generics and goroutines. The main function Sleep[V ds.Integer](a ds.ArrayList[V]) ds.ArrayList[V] takes a generic ArrayList as input and returns a sorted ArrayList. The code creates a separate goroutine for each element in the input array, sleeps for a duration proportional to the element's value, and then sends the element to a channel. Another goroutine waits for all the sleeping goroutines to finish and then closes the channel. The sorted result ArrayList is constructed by appending the elements received from the channel in the order they arrive. The sync.WaitGroup is used to synchronize goroutines and ensure that all of them have completed before closing the channel.
+

Testing



For testing, we only allow values up to 10, as otherwise, it would take too long to finish:
diff --git a/gemfeed/atom.xml b/gemfeed/atom.xml index 91d120e8..ec4e5951 100644 --- a/gemfeed/atom.xml +++ b/gemfeed/atom.xml @@ -1,6 +1,6 @@ - 2023-04-09T22:38:01+03:00 + 2023-04-09T23:03:53+03:00 foo.zone feed To be in the .zone! @@ -230,6 +230,8 @@ http://www.gnu.org/software/src-highlite --> }
+This Go code implements the sleep sort algorithm using generics and goroutines. The main function Sleep[V ds.Integer](a ds.ArrayList[V]) ds.ArrayList[V] takes a generic ArrayList as input and returns a sorted ArrayList. The code creates a separate goroutine for each element in the input array, sleeps for a duration proportional to the element's value, and then sends the element to a channel. Another goroutine waits for all the sleeping goroutines to finish and then closes the channel. The sorted result ArrayList is constructed by appending the elements received from the channel in the order they arrive. The sync.WaitGroup is used to synchronize goroutines and ensure that all of them have completed before closing the channel.
+

Testing



For testing, we only allow values up to 10, as otherwise, it would take too long to finish:
-- cgit v1.2.3