diff options
| -rw-r--r-- | gemfeed/2023-04-09-algorithms-and-data-structures-in-golang-part-1.gmi | 2 | ||||
| -rw-r--r-- | gemfeed/2023-04-09-algorithms-and-data-structures-in-golang-part-1.gmi.tpl | 2 | ||||
| -rw-r--r-- | gemfeed/atom.xml | 4 | ||||
| -rw-r--r-- | index.gmi | 2 | ||||
| -rw-r--r-- | uptime-stats.gmi | 2 |
5 files changed, 9 insertions, 3 deletions
diff --git a/gemfeed/2023-04-09-algorithms-and-data-structures-in-golang-part-1.gmi b/gemfeed/2023-04-09-algorithms-and-data-structures-in-golang-part-1.gmi index 13672636..31fa782b 100644 --- a/gemfeed/2023-04-09-algorithms-and-data-structures-in-golang-part-1.gmi +++ b/gemfeed/2023-04-09-algorithms-and-data-structures-in-golang-part-1.gmi @@ -189,6 +189,8 @@ func Sleep[V ds.Integer](a ds.ArrayList[V]) ds.ArrayList[V] { } ``` +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/2023-04-09-algorithms-and-data-structures-in-golang-part-1.gmi.tpl b/gemfeed/2023-04-09-algorithms-and-data-structures-in-golang-part-1.gmi.tpl index 1bbc1120..98daf815 100644 --- a/gemfeed/2023-04-09-algorithms-and-data-structures-in-golang-part-1.gmi.tpl +++ b/gemfeed/2023-04-09-algorithms-and-data-structures-in-golang-part-1.gmi.tpl @@ -189,6 +189,8 @@ func Sleep[V ds.Integer](a ds.ArrayList[V]) ds.ArrayList[V] { } ``` +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 4ee14fa2..fb629b3b 100644 --- a/gemfeed/atom.xml +++ b/gemfeed/atom.xml @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="utf-8"?> <feed xmlns="http://www.w3.org/2005/Atom"> - <updated>2023-04-09T22:38:01+03:00</updated> + <updated>2023-04-09T23:03:53+03:00</updated> <title>foo.zone feed</title> <subtitle>To be in the .zone!</subtitle> <link href="gemini://foo.zone/gemfeed/atom.xml" rel="self" /> @@ -230,6 +230,8 @@ http://www.gnu.org/software/src-highlite --> <font color="#FF0000">}</font> </pre> <br /> +<span>This Go code implements the sleep sort algorithm using generics and goroutines. The main function <span class='inlinecode'>Sleep[V ds.Integer](a ds.ArrayList[V]) ds.ArrayList[V]</span> takes a generic <span class='inlinecode'>ArrayList</span> as input and returns a sorted <span class='inlinecode'>ArrayList</span>. 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 <span class='inlinecode'>ArrayList</span> is constructed by appending the elements received from the channel in the order they arrive. The <span class='inlinecode'>sync.WaitGroup</span> is used to synchronize goroutines and ensure that all of them have completed before closing the channel.</span><br /> +<br /> <h3 style='display: inline'>Testing</h3><br /> <br /> <span>For testing, we only allow values up to 10, as otherwise, it would take too long to finish:</span><br /> @@ -1,6 +1,6 @@ # foo.zone -> This site was generated at 2023-04-09T22:38:01+03:00 by `Gemtexter` +> This site was generated at 2023-04-09T23:03:53+03:00 by `Gemtexter` ``` |\---/| diff --git a/uptime-stats.gmi b/uptime-stats.gmi index 5749c799..6c2c25c2 100644 --- a/uptime-stats.gmi +++ b/uptime-stats.gmi @@ -1,6 +1,6 @@ # My machine uptime stats -> This site was last updated at 2023-04-09T22:38:01+03:00 +> This site was last updated at 2023-04-09T23:03:53+03:00 The following stats were collected via `uptimed` on all of my personal computers over many years and the output was generated by `guprecords`, the global uptime records stats analyser of mine. |
