diff options
| author | Paul Buetow <paul@buetow.org> | 2024-09-27 23:28:33 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2024-09-27 23:28:33 +0300 |
| commit | 97decc24069b655e0a1d32e3e6217ab0d8653351 (patch) | |
| tree | 6020e7cbfcde170c346f913f6a35f8fd8965bbea | |
| parent | e3f4f9eae027af0af44532aa84826c7f78a04508 (diff) | |
Update content for gemtext
| -rw-r--r-- | about/index.gmi | 2 | ||||
| -rw-r--r-- | about/resources.gmi | 152 | ||||
| -rw-r--r-- | gemfeed/2024-03-03-a-fine-fyne-android-app-for-quickly-logging-ideas-programmed-in-golang.gmi | 1 | ||||
| -rw-r--r-- | gemfeed/atom.xml | 810 | ||||
| -rw-r--r-- | gemfeed/index.gmi | 1 | ||||
| -rw-r--r-- | index.gmi | 3 | ||||
| -rw-r--r-- | notes/search-inside-yourself.gmi | 20 | ||||
| -rw-r--r-- | uptime-stats.gmi | 2 |
8 files changed, 620 insertions, 371 deletions
diff --git a/about/index.gmi b/about/index.gmi index de2b76e4..788b135b 100644 --- a/about/index.gmi +++ b/about/index.gmi @@ -2,7 +2,7 @@ * Name: Paul Buetow * Profession: Computerist - Solving problems with computers that we wouldn't have without them -* Current job title: Site Reliability Engineer +* Current job title: Principal Site Reliability Engineer * E-Mail: `paul@nospam.buetow.org` => ./paul.jpg Paul Buetow diff --git a/about/resources.gmi b/about/resources.gmi index e89cd7bb..cf3ee99b 100644 --- a/about/resources.gmi +++ b/about/resources.gmi @@ -33,93 +33,93 @@ You won't find any links on this site because, over time, the links will break. In random order: -* Modern Perl; Chromatic ; Onyx Neon Press -* Effective awk programming; Arnold Robbins; O'Reilly -* DNS and BIND; Cricket Liu; O'Reilly +* 97 things every SRE should know; Emil Stolarsky, Jaime Woo; O'Reilly * Raku Recipes; J.J. Merelo; Apress -* Perl New Features; Joshua McAdams, brian d foy; Perl School -* Raku Fundamentals; Moritz Lenz; Apress -* 100 Go Mistakes and How to Avoid Them; Teiva Harsanyi; Manning Publications -* 21st Century C: C Tips from the New School; Ben Klemens; O'Reilly -* Effective Java; Joshua Bloch; Addison-Wesley Professional -* Object-Oriented Programming with ANSI-C; Axel-Tobias Schreiner -* Programming Perl aka "The Camel Book"; Tom Christiansen, brian d foy, Larry Wall & Jon Orwant; O'Reilly +* Clusterbau mit Linux-HA; Michael Schwartzkopff; O'Reilly +* Concurrency in Go; Katherine Cox-Buday; O'Reilly +* Leanring eBPF; Liz Rice; O'Reilly * The Go Programming Language; Alan A. A. Donovan; Addison-Wesley Professional -* The DevOps Handbook; Gene Kim, Jez Humble, Patrick Debois, John Willis; Audible -* Learn You Some Erlang for Great Good; Fred Herbert; No Starch Press -* Go Brain Teasers - Exercise Your Mind; Miki Tebeka; The Pragmatic Programmers -* Funktionale Programmierung; Peter Pepper; Springer -* C++ Programming Language; Bjarne Stroustrup; -* Systemprogrammierung in Go; Frank Müller; dpunkt -* The Docker Book; James Turnbull; Kindle -* Site Reliability Engineering; How Google runs production systems; O'Reilly -* DevOps And Site Reliability Engineering Handbook; Stephen Fleming; Audible +* Polished Ruby Programming; Jeremy Evans; Packt Publishing +* Modern Perl; Chromatic ; Onyx Neon Press * Learn You a Haskell for Great Good!; Miran Lipovaca; No Starch Press -* Java ist auch eine Insel; Christian Ullenboom; -* Concurrency in Go; Katherine Cox-Buday; O'Reilly +* Learn You Some Erlang for Great Good; Fred Herbert; No Starch Press +* The DevOps Handbook; Gene Kim, Jez Humble, Patrick Debois, John Willis; Audible +* Ultimate Go Notebook; Bill Kennedy * Amazon Web Services in Action; Michael Wittig and Andreas Wittig; Manning Publications +* Object-Oriented Programming with ANSI-C; Axel-Tobias Schreiner +* Data Science at the Command Line; Jeroen Janssens; O'Reilly +* 100 Go Mistakes and How to Avoid Them; Teiva Harsanyi; Manning Publications * Pro Puppet; James Turnbull, Jeffrey McCune; Apress +* DevOps And Site Reliability Engineering Handbook; Stephen Fleming; Audible +* Site Reliability Engineering; How Google runs production systems; O'Reilly +* The Docker Book; James Turnbull; Kindle +* Distributed Systems: Principles and Paradigms; Andrew S. Tanenbaum; Pearson +* Programming Perl aka "The Camel Book"; Tom Christiansen, brian d foy, Larry Wall & Jon Orwant; O'Reilly +* Systems Performance Tuning; Gian-Paolo D. Musumeci and others...; O'Reilly +* 21st Century C: C Tips from the New School; Ben Klemens; O'Reilly * The Practise of System and Network Administration; Thomas A. Limoncelli, Christina J. Hogan, Strata R. Chalup; Addison-Wesley Professional Pro Git; Scott Chacon, Ben Straub; Apress * The Pragmatic Programmer; David Thomas; Addison-Wesley -* Systems Performance Tuning; Gian-Paolo D. Musumeci and others...; O'Reilly +* Think Raku (aka Think Perl 6); Laurent Rosenfeld, Allen B. Downey; O'Reilly +* Go Brain Teasers - Exercise Your Mind; Miki Tebeka; The Pragmatic Programmers +* DNS and BIND; Cricket Liu; O'Reilly +* Java ist auch eine Insel; Christian Ullenboom; * Higher Order Perl; Mark Dominus; Morgan Kaufmann -* Leanring eBPF; Liz Rice; O'Reilly -* Ultimate Go Notebook; Bill Kennedy -* Distributed Systems: Principles and Paradigms; Andrew S. Tanenbaum; Pearson -* Clusterbau mit Linux-HA; Michael Schwartzkopff; O'Reilly -* Polished Ruby Programming; Jeremy Evans; Packt Publishing -* Data Science at the Command Line; Jeroen Janssens; O'Reilly -* 97 things every SRE should know; Emil Stolarsky, Jaime Woo; O'Reilly -* Tmux 2: Productive Mouse-free Development; Brain P. Hogan; The Pragmatic Programmers +* Raku Fundamentals; Moritz Lenz; Apress +* Effective Java; Joshua Bloch; Addison-Wesley Professional * Developing Games in Java; David Brackeen and others...; New Riders -* Think Raku (aka Think Perl 6); Laurent Rosenfeld, Allen B. Downey; O'Reilly +* Tmux 2: Productive Mouse-free Development; Brain P. Hogan; The Pragmatic Programmers +* Perl New Features; Joshua McAdams, brian d foy; Perl School +* Effective awk programming; Arnold Robbins; O'Reilly +* Systemprogrammierung in Go; Frank Müller; dpunkt +* C++ Programming Language; Bjarne Stroustrup; +* Funktionale Programmierung; Peter Pepper; Springer ## Technical references I didn't read them from the beginning to the end, but I am using them to look up things. The books are in random order: -* Implementing Service Level Objectives; Alex Hidalgo; O'Reilly -* Relayd and Httpd Mastery; Michael W Lucas -* Algorithms; Robert Sedgewick, Kevin Wayne; Addison Wesley -* The Linux Programming Interface; Michael Kerrisk; No Starch Press -* BPF Performance Tools - Linux System and Application Observability, Brendan Gregg; Addison Wesley * Understanding the Linux Kernel; Daniel P. Bovet, Marco Cesati; O'Reilly +* BPF Performance Tools - Linux System and Application Observability, Brendan Gregg; Addison Wesley +* Relayd and Httpd Mastery; Michael W Lucas +* Implementing Service Level Objectives; Alex Hidalgo; O'Reilly * Groovy Kurz & Gut; Joerg Staudemeier; O'Reilly +* The Linux Programming Interface; Michael Kerrisk; No Starch Press +* Algorithms; Robert Sedgewick, Kevin Wayne; Addison Wesley ## Self-development and soft-skills books In random order: -* Deep Work; Cal Newport; Piatkus +* The Complete Software Developer's Career Guide; John Sonmez; Unabridged Audiobook +* Slow Productivity; Cal Newport; Penguin Random House * Stop starting, start finishing; Arne Roock; Lean-Kanban University -* The Phoenix Project - A Novel About IT, DevOps, and Helping your Business Win; Gene Kim and Kevin Behr; Trade Select -* Time Management for System Administrators; Thomas A. Limoncelli; O'Reilly +* The Off Switch; Mark Cropley; Virgin Books +* 101 Essays that change the way you think; Brianna Wiest; Audible +* Psycho-Cybernetics; Maxwell Maltz; Perigee Books * The Bullet Journal Method; Ryder Carroll; Fourth Estate -* So Good They Can't Ignore You; Cal Newport; Business Plus -* Never Split the Difference; Chris Voss, Tahl Raz; Random House Business -* Staff Engineer: Leadership beyond the management track; Will Larson; Audible -* Slow Productivity; Cal Newport; Penguin Random House +* The Obstacle Is The Way; Ryan Holiday; Profile Books Ltd +* Consciousness: A Very Short Introduction; Susan Blackmore; Oxford Uiversity Press * Search Inside Yourself - The Unexpected path to Achieving Success, Happiness (and World Peace); Chade-Meng Tan, Daniel Goleman, Jon Kabat-Zinn; HarperOne +* The Daily Stoic; Ryan Holiday, Stephen Hanselman; Profile Books +* Influence without Authority; A. Cohen, D. Bradford; Wiley +* So Good They Can't Ignore You; Cal Newport; Business Plus * Eat That Frog!; Brian Tracy; Hodder Paperbacks -* The Off Switch; Mark Cropley; Virgin Books -* The Obstacle Is The Way; Ryan Holiday; Profile Books Ltd * Atomic Habits; James Clear; Random House Business -* Digital Minimalism; Cal Newport; Portofolio Penguin -* Who Moved My Cheese?; Dr. Spencer Johnson; Vermilion -* The Complete Software Developer's Career Guide; John Sonmez; Unabridged Audiobook +* Soft Skills; John Sommez; Manning Publications * The 7 Habits Of Highly Effective People; Stephen R. Covey; Simon & Schuster UK * The Power of Now; Eckhard Tolle; Yellow Kite +* Never Split the Difference; Chris Voss, Tahl Raz; Random House Business +* Who Moved My Cheese?; Dr. Spencer Johnson; Vermilion +* The Phoenix Project - A Novel About IT, DevOps, and Helping your Business Win; Gene Kim and Kevin Behr; Trade Select +* Ultralearning; Anna Laurent; Self-published via Amazon * The Good Enough Job; Simone Stolzoff; Ebury Edge -* The Joy of Missing Out; Christina Crook; New Society Publishers -* Psycho-Cybernetics; Maxwell Maltz; Perigee Books +* Digital Minimalism; Cal Newport; Portofolio Penguin +* Time Management for System Administrators; Thomas A. Limoncelli; O'Reilly * Ultralearning; Scott Young; Thorsons -* Soft Skills; John Sommez; Manning Publications -* 101 Essays that change the way you think; Brianna Wiest; Audible * Buddah and Einstein walk into a Bar; Guy Joseph Ale, Claire Bloom; Blackstone Publishing -* Influence without Authority; A. Cohen, D. Bradford; Wiley -* The Daily Stoic; Ryan Holiday, Stephen Hanselman; Profile Books -* Ultralearning; Anna Laurent; Self-published via Amazon -* Consciousness: A Very Short Introduction; Susan Blackmore; Oxford Uiversity Press +* The Joy of Missing Out; Christina Crook; New Society Publishers +* Staff Engineer: Leadership beyond the management track; Will Larson; Audible +* Deep Work; Cal Newport; Piatkus => https://foo.zone/notes/index.html Here are notes of mine for some of the books (HTTP) => gemini://foo.zone/notes/index.gmi Here are notes of mine for some of the books (Gemini) @@ -128,22 +128,22 @@ In random order: Some of these were in-person with exams; others were online learning lectures only. In random order: -* The Well-Grounded Rubyist Video Edition; David. A. Black; O'Reilly Online -* Developing IaC with Terraform (with Live Lessons); O'Reilly Online -* AWS Immersion Day; Amazon; 1-day interactive online training -* Linux Security and Isolation APIs Training; Michael Kerrisk; 3-day on-site training -* Protocol buffers; O'Reilly Online * Apache Tomcat Best Practises; 3-day on-site training +* F5 Loadbalancers Training; 2-day on-site training; F5, Inc. * The Ultimate Kubernetes Bootcamp; School of Devops; O'Reilly Online +* MySQL Deep Dive Workshop; 2-day on-site training +* AWS Immersion Day; Amazon; 1-day interactive online training +* Developing IaC with Terraform (with Live Lessons); O'Reilly Online +* Red Hat Certified System Administrator; Course + certification (Although I had the option, I decided not to take the next course as it is more effective to self learn what I need) +* Functional programming lecture; Remote University of Hagen * Scripting Vim; Damian Conway; O'Reilly Online +* Cloud Operations on AWS - Learn how to configure, deploy, maintain, and troubleshoot your AWS environments; 3-day online live training with labs; Amazon * Structure and Interpretation of Computer Programs; Harold Abelson and more...; -* Red Hat Certified System Administrator; Course + certification (Although I had the option, I decided not to take the next course as it is more effective to self learn what I need) -* MySQL Deep Dive Workshop; 2-day on-site training +* Protocol buffers; O'Reilly Online +* The Well-Grounded Rubyist Video Edition; David. A. Black; O'Reilly Online * Ultimate Go Programming; Bill Kennedy; O'Reilly Online -* F5 Loadbalancers Training; 2-day on-site training; F5, Inc. -* Cloud Operations on AWS - Learn how to configure, deploy, maintain, and troubleshoot your AWS environments; 3-day online live training with labs; Amazon * Algorithms Video Lectures; Robert Sedgewick; O'Reilly Online -* Functional programming lecture; Remote University of Hagen +* Linux Security and Isolation APIs Training; Michael Kerrisk; 3-day on-site training ## Technical guides @@ -156,30 +156,30 @@ These are not whole books, but guides (smaller or larger) which I found very use In random order: +* Ship it (Changelog) +* Maintainable * Backend Banter -* Modern Mentor * Cup o' Go [Golang] -* Ship it (Changelog) -* Hidden Brain * Deep Questions with Cal Newport +* Hidden Brain +* Go Time (Changelog) +* Modern Mentor * Java Pub House * Dev Interrupted -* Maintainable -* Go Time (Changelog) ## Newsletters I like This is a mix of tech and non-tech newsletters I am subscribed to. In random order: -* byteSizeGo -* VK Newsletter +* Golang Weekly * Register Spill -* Ruby Weekly -* The Imperfectionist +* VK Newsletter * Andreas Brandhorst Newsletter (Sci-Fi author) +* Ruby Weekly * The Valuable Dev -* Golang Weekly * Applied Go Weekly Newsletter +* The Imperfectionist +* byteSizeGo # Formal education diff --git a/gemfeed/2024-03-03-a-fine-fyne-android-app-for-quickly-logging-ideas-programmed-in-golang.gmi b/gemfeed/2024-03-03-a-fine-fyne-android-app-for-quickly-logging-ideas-programmed-in-golang.gmi index 1d62ffa7..e767ecb3 100644 --- a/gemfeed/2024-03-03-a-fine-fyne-android-app-for-quickly-logging-ideas-programmed-in-golang.gmi +++ b/gemfeed/2024-03-03-a-fine-fyne-android-app-for-quickly-logging-ideas-programmed-in-golang.gmi @@ -54,7 +54,6 @@ E-Mail your comments to `paul@nospam.buetow.org` :-) Other Go related posts are: -=> ./2023-04-09-algorithms-and-data-structures-in-golang-part-1.gmi 2023-04-09 Algorithms and Data Structures in Go - Part 1 => ./2024-03-03-a-fine-fyne-android-app-for-quickly-logging-ideas-programmed-in-golang.gmi 2024-03-03 A fine Fyne Android app for quickly logging ideas programmed in Go (You are currently reading this) => ../ Back to the main site diff --git a/gemfeed/atom.xml b/gemfeed/atom.xml index 3ee013e2..3debfd20 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>2024-09-17T05:21:15+03:00</updated> + <updated>2024-09-27T23:27:37+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" /> @@ -2275,7 +2275,6 @@ http://www.gnu.org/software/src-highlite --> <br /> <span>Other Go related posts are:</span><br /> <br /> -<a class='textlink' href='./2023-04-09-algorithms-and-data-structures-in-golang-part-1.html'>2023-04-09 Algorithms and Data Structures in Go - Part 1</a><br /> <a class='textlink' href='./2024-03-03-a-fine-fyne-android-app-for-quickly-logging-ideas-programmed-in-golang.html'>2024-03-03 A fine Fyne Android app for quickly logging ideas programmed in Go (You are currently reading this)</a><br /> <br /> <a class='textlink' href='../'>Back to the main site</a><br /> @@ -5122,289 +5121,6 @@ no1 in 455 days, 18:52:44 | at Sun Jul 21 07:37:51 2024 </content> </entry> <entry> - <title>Algorithms and Data Structures in Go - Part 1</title> - <link href="gemini://foo.zone/gemfeed/2023-04-09-algorithms-and-data-structures-in-golang-part-1.gmi" /> - <id>gemini://foo.zone/gemfeed/2023-04-09-algorithms-and-data-structures-in-golang-part-1.gmi</id> - <updated>2023-04-09T22:31:42+03:00</updated> - <author> - <name>Paul Buetow aka snonux</name> - <email>paul@dev.buetow.org</email> - </author> - <summary>This is the first blog post about my Algorithms and Data Structures in Go series. I am not a Software Developer in my day job. In my current role, programming and scripting skills are desirable but not mandatory. I have been learning about Data Structures and Algorithms many years ago at University. I thought it would be fun to revisit/refresh my knowledge here and implement many of the algorithms in Go.</summary> - <content type="xhtml"> - <div xmlns="http://www.w3.org/1999/xhtml"> - <h1 style='display: inline' id='algorithms-and-data-structures-in-go---part-1'>Algorithms and Data Structures in Go - Part 1</h1><br /> -<br /> -<span class='quote'>Published at 2023-04-09T22:31:42+03:00</span><br /> -<br /> -<span>This is the first blog post about my Algorithms and Data Structures in Go series. I am not a Software Developer in my day job. In my current role, programming and scripting skills are desirable but not mandatory. I have been learning about Data Structures and Algorithms many years ago at University. I thought it would be fun to revisit/refresh my knowledge here and implement many of the algorithms in Go.</span><br /> -<br /> -<a class='textlink' href='./2023-04-09-algorithms-and-data-structures-in-golang-part-1.html'>2023-04-09 Algorithms and Data Structures in Go - Part 1 (You are currently reading this)</a><br /> -<br /> -<span>This post is about setting up some basic data structures and methods for this blog series. I promise, everything will be easy to follow in this post. It will become more interesting later in this series.</span><br /> -<br /> -<pre> - ,_---~~~~~----._ - _,,_,*^____ _____``*g*\"*, - / __/ /' ^. / \ ^@q f -[ @f | @)) | | @)) l 0 _/ - \`/ \~____ / __ \_____/ \ - | _l__l_ I - } [______] I - ] | | | | - ] ~ ~ | - | | - | | -</pre> -<br /> -<h2 style='display: inline' id='table-of-contents'>Table of Contents</h2><br /> -<br /> -<ul> -<li><a href='#algorithms-and-data-structures-in-go---part-1'>Algorithms and Data Structures in Go - Part 1</a></li> -<li>⇢ <a href='#type-constraints'>Type constraints</a></li> -<li>⇢ <a href='#arraylist'>ArrayList</a></li> -<li>⇢ <a href='#helper-methods'>Helper methods</a></li> -<li>⇢ <a href='#sleep-sort'>Sleep sort</a></li> -<li>⇢ ⇢ <a href='#testing'>Testing</a></li> -</ul><br /> -<h2 style='display: inline' id='type-constraints'>Type constraints</h2><br /> -<br /> -<span>First, the package <span class='inlinecode'>ds</span> (data structures) defines the <span class='inlinecode'>types.go</span>. All examples will either operate on the <span class='inlinecode'>Integer</span> or <span class='inlinecode'>Number</span> type:</span><br /> -<br /> -<!-- Generator: GNU source-highlight 3.1.9 -by Lorenzo Bettini -http://www.lorenzobettini.it -http://www.gnu.org/software/src-highlite --> -<pre><b><font color="#ffffff">package</font></b><font color="#ff0000"> ds</font> - -<b><font color="#ffffff">import</font></b><font color="#ff0000"> </font><font color="#F3E651">(</font> -<font color="#ff0000"> </font><font color="#bb00ff">"golang.org/x/exp/constraints"</font> -<font color="#F3E651">)</font> - -<b><font color="#ffffff">type</font></b><font color="#ff0000"> Integer </font><b><font color="#ffffff">interface</font></b><font color="#ff0000"> </font><font color="#F3E651">{</font> -<font color="#ff0000"> constraints</font><font color="#F3E651">.</font><font color="#ff0000">Integer</font> -<font color="#F3E651">}</font> - -<b><font color="#ffffff">type</font></b><font color="#ff0000"> Number </font><b><font color="#ffffff">interface</font></b><font color="#ff0000"> </font><font color="#F3E651">{</font> -<font color="#ff0000"> constraints</font><font color="#F3E651">.</font><font color="#ff0000">Integer </font><font color="#F3E651">|</font><font color="#ff0000"> constraints</font><font color="#F3E651">.</font><font color="#ff0000">Float</font> -<font color="#F3E651">}</font> - -</pre> -<br /> -<h2 style='display: inline' id='arraylist'>ArrayList</h2><br /> -<br /> -<span>Next comes the <span class='inlinecode'>arraylist.go</span>, which defines the underlying data structure all the algorithms of this series will use. <span class='inlinecode'>ArrayList</span> is just a type alias of a Go array (or slice) with custom methods on it:</span><br /> -<br /> -<!-- Generator: GNU source-highlight 3.1.9 -by Lorenzo Bettini -http://www.lorenzobettini.it -http://www.gnu.org/software/src-highlite --> -<pre><b><font color="#ffffff">package</font></b><font color="#ff0000"> ds</font> - -<b><font color="#ffffff">import</font></b><font color="#ff0000"> </font><font color="#F3E651">(</font> -<font color="#ff0000"> </font><font color="#bb00ff">"fmt"</font> -<font color="#ff0000"> </font><font color="#bb00ff">"math/rand"</font> -<font color="#ff0000"> </font><font color="#bb00ff">"strings"</font> -<font color="#F3E651">)</font> - -<b><font color="#ffffff">type</font></b><font color="#ff0000"> ArrayList</font><font color="#F3E651">[</font><font color="#ff0000">V Number</font><font color="#F3E651">]</font><font color="#ff0000"> </font><font color="#F3E651">[]</font><font color="#ff0000">V</font> - -<b><font color="#ffffff">func</font></b><font color="#ff0000"> NewArrayList</font><font color="#F3E651">[</font><font color="#ff0000">V Number</font><font color="#F3E651">](</font><font color="#ff0000">l int</font><font color="#F3E651">)</font><font color="#ff0000"> ArrayList</font><font color="#F3E651">[</font><font color="#ff0000">V</font><font color="#F3E651">]</font><font color="#ff0000"> </font><font color="#F3E651">{</font> -<font color="#ff0000"> </font><b><font color="#ffffff">return</font></b><font color="#ff0000"> </font><font color="#7bc710">make</font><font color="#F3E651">(</font><font color="#ff0000">ArrayList</font><font color="#F3E651">[</font><font color="#ff0000">V</font><font color="#F3E651">],</font><font color="#ff0000"> l</font><font color="#F3E651">)</font> -<font color="#F3E651">}</font> -</pre> -<br /> -<span>As you can see, the code uses Go generics, which I refactored recently. Besides the default constructor (which only returns an empty <span class='inlinecode'>ArrayList</span> with a given capacity), there are also a bunch of special constructors. <span class='inlinecode'>NewRandomArrayList</span> is returning an <span class='inlinecode'>ArrayList</span> with random numbers, <span class='inlinecode'>NewAscendingArrayList</span> and <span class='inlinecode'>NewDescendingArrayList</span> are returning <span class='inlinecode'>ArrayList</span>s in either ascending or descending order. They all will be used later on for testing and benchmarking the algorithms.</span><br /> -<br /> -<!-- Generator: GNU source-highlight 3.1.9 -by Lorenzo Bettini -http://www.lorenzobettini.it -http://www.gnu.org/software/src-highlite --> -<pre><b><font color="#ffffff">func</font></b><font color="#ff0000"> NewRandomArrayList</font><font color="#F3E651">[</font><font color="#ff0000">V Number</font><font color="#F3E651">](</font><font color="#ff0000">l</font><font color="#F3E651">,</font><font color="#ff0000"> max int</font><font color="#F3E651">)</font><font color="#ff0000"> ArrayList</font><font color="#F3E651">[</font><font color="#ff0000">V</font><font color="#F3E651">]</font><font color="#ff0000"> </font><font color="#F3E651">{</font> -<font color="#ff0000"> a </font><font color="#F3E651">:=</font><font color="#ff0000"> </font><font color="#7bc710">make</font><font color="#F3E651">(</font><font color="#ff0000">ArrayList</font><font color="#F3E651">[</font><font color="#ff0000">V</font><font color="#F3E651">],</font><font color="#ff0000"> l</font><font color="#F3E651">)</font> -<font color="#ff0000"> </font><b><font color="#ffffff">for</font></b><font color="#ff0000"> i </font><font color="#F3E651">:=</font><font color="#ff0000"> </font><font color="#bb00ff">0</font><font color="#F3E651">;</font><font color="#ff0000"> i </font><font color="#F3E651"><</font><font color="#ff0000"> l</font><font color="#F3E651">;</font><font color="#ff0000"> i</font><font color="#F3E651">++</font><font color="#ff0000"> </font><font color="#F3E651">{</font> -<font color="#ff0000"> </font><b><font color="#ffffff">if</font></b><font color="#ff0000"> max </font><font color="#F3E651">></font><font color="#ff0000"> </font><font color="#bb00ff">0</font><font color="#ff0000"> </font><font color="#F3E651">{</font> -<font color="#ff0000"> a</font><font color="#F3E651">[</font><font color="#ff0000">i</font><font color="#F3E651">]</font><font color="#ff0000"> </font><font color="#F3E651">=</font><font color="#ff0000"> </font><font color="#7bc710">V</font><font color="#F3E651">(</font><font color="#ff0000">rand</font><font color="#F3E651">.</font><font color="#7bc710">Intn</font><font color="#F3E651">(</font><font color="#ff0000">max</font><font color="#F3E651">))</font> -<font color="#ff0000"> </font><b><font color="#ffffff">continue</font></b> -<font color="#ff0000"> </font><font color="#F3E651">}</font> -<font color="#ff0000"> a</font><font color="#F3E651">[</font><font color="#ff0000">i</font><font color="#F3E651">]</font><font color="#ff0000"> </font><font color="#F3E651">=</font><font color="#ff0000"> </font><font color="#7bc710">V</font><font color="#F3E651">(</font><font color="#ff0000">rand</font><font color="#F3E651">.</font><font color="#7bc710">Int</font><font color="#F3E651">())</font> -<font color="#ff0000"> </font><font color="#F3E651">}</font> -<font color="#ff0000"> </font><b><font color="#ffffff">return</font></b><font color="#ff0000"> a</font> -<font color="#F3E651">}</font> - -<b><font color="#ffffff">func</font></b><font color="#ff0000"> NewAscendingArrayList</font><font color="#F3E651">[</font><font color="#ff0000">V Number</font><font color="#F3E651">](</font><font color="#ff0000">l int</font><font color="#F3E651">)</font><font color="#ff0000"> ArrayList</font><font color="#F3E651">[</font><font color="#ff0000">V</font><font color="#F3E651">]</font><font color="#ff0000"> </font><font color="#F3E651">{</font> -<font color="#ff0000"> a </font><font color="#F3E651">:=</font><font color="#ff0000"> </font><font color="#7bc710">make</font><font color="#F3E651">(</font><font color="#ff0000">ArrayList</font><font color="#F3E651">[</font><font color="#ff0000">V</font><font color="#F3E651">],</font><font color="#ff0000"> l</font><font color="#F3E651">)</font> -<font color="#ff0000"> </font><b><font color="#ffffff">for</font></b><font color="#ff0000"> i </font><font color="#F3E651">:=</font><font color="#ff0000"> </font><font color="#bb00ff">0</font><font color="#F3E651">;</font><font color="#ff0000"> i </font><font color="#F3E651"><</font><font color="#ff0000"> l</font><font color="#F3E651">;</font><font color="#ff0000"> i</font><font color="#F3E651">++</font><font color="#ff0000"> </font><font color="#F3E651">{</font> -<font color="#ff0000"> a</font><font color="#F3E651">[</font><font color="#ff0000">i</font><font color="#F3E651">]</font><font color="#ff0000"> </font><font color="#F3E651">=</font><font color="#ff0000"> </font><font color="#7bc710">V</font><font color="#F3E651">(</font><font color="#ff0000">i</font><font color="#F3E651">)</font> -<font color="#ff0000"> </font><font color="#F3E651">}</font> -<font color="#ff0000"> </font><b><font color="#ffffff">return</font></b><font color="#ff0000"> a</font> -<font color="#F3E651">}</font> - -<b><font color="#ffffff">func</font></b><font color="#ff0000"> NewDescendingArrayList</font><font color="#F3E651">[</font><font color="#ff0000">V Number</font><font color="#F3E651">](</font><font color="#ff0000">l int</font><font color="#F3E651">)</font><font color="#ff0000"> ArrayList</font><font color="#F3E651">[</font><font color="#ff0000">V</font><font color="#F3E651">]</font><font color="#ff0000"> </font><font color="#F3E651">{</font> -<font color="#ff0000"> a </font><font color="#F3E651">:=</font><font color="#ff0000"> </font><font color="#7bc710">make</font><font color="#F3E651">(</font><font color="#ff0000">ArrayList</font><font color="#F3E651">[</font><font color="#ff0000">V</font><font color="#F3E651">],</font><font color="#ff0000"> l</font><font color="#F3E651">)</font> -<font color="#ff0000"> j </font><font color="#F3E651">:=</font><font color="#ff0000"> l </font><font color="#F3E651">-</font><font color="#ff0000"> </font><font color="#bb00ff">1</font> -<font color="#ff0000"> </font><b><font color="#ffffff">for</font></b><font color="#ff0000"> i </font><font color="#F3E651">:=</font><font color="#ff0000"> </font><font color="#bb00ff">0</font><font color="#F3E651">;</font><font color="#ff0000"> i </font><font color="#F3E651"><</font><font color="#ff0000"> l</font><font color="#F3E651">;</font><font color="#ff0000"> i</font><font color="#F3E651">++</font><font color="#ff0000"> </font><font color="#F3E651">{</font> -<font color="#ff0000"> a</font><font color="#F3E651">[</font><font color="#ff0000">i</font><font color="#F3E651">]</font><font color="#ff0000"> </font><font color="#F3E651">=</font><font color="#ff0000"> </font><font color="#7bc710">V</font><font color="#F3E651">(</font><font color="#ff0000">j</font><font color="#F3E651">)</font> -<font color="#ff0000"> j</font><font color="#F3E651">--</font> -<font color="#ff0000"> </font><font color="#F3E651">}</font> -<font color="#ff0000"> </font><b><font color="#ffffff">return</font></b><font color="#ff0000"> a</font> -<font color="#F3E651">}</font> -</pre> -<br /> -<h2 style='display: inline' id='helper-methods'>Helper methods</h2><br /> -<br /> -<span>The <span class='inlinecode'>FirstN</span> method only returns the first N elements of the <span class='inlinecode'>ArrayList</span>. This is useful for printing out only parts of the data structure:</span><br /> -<br /> -<!-- Generator: GNU source-highlight 3.1.9 -by Lorenzo Bettini -http://www.lorenzobettini.it -http://www.gnu.org/software/src-highlite --> -<pre><b><font color="#ffffff">func</font></b><font color="#ff0000"> </font><font color="#F3E651">(</font><font color="#ff0000">a ArrayList</font><font color="#F3E651">[</font><font color="#ff0000">V</font><font color="#F3E651">])</font><font color="#ff0000"> </font><font color="#7bc710">FirstN</font><font color="#F3E651">(</font><font color="#ff0000">n int</font><font color="#F3E651">)</font><font color="#ff0000"> </font><b><font color="#F35E1E">string</font></b><font color="#ff0000"> </font><font color="#F3E651">{</font> -<font color="#ff0000"> </font><b><font color="#ffffff">var</font></b><font color="#ff0000"> sb strings</font><font color="#F3E651">.</font><font color="#ff0000">Builder</font> -<font color="#ff0000"> j </font><font color="#F3E651">:=</font><font color="#ff0000"> n</font> - -<font color="#ff0000"> l </font><font color="#F3E651">:=</font><font color="#ff0000"> </font><font color="#7bc710">len</font><font color="#F3E651">(</font><font color="#ff0000">a</font><font color="#F3E651">)</font> -<font color="#ff0000"> </font><b><font color="#ffffff">if</font></b><font color="#ff0000"> j </font><font color="#F3E651">></font><font color="#ff0000"> l </font><font color="#F3E651">{</font> -<font color="#ff0000"> j </font><font color="#F3E651">=</font><font color="#ff0000"> l</font> -<font color="#ff0000"> </font><font color="#F3E651">}</font> - -<font color="#ff0000"> </font><b><font color="#ffffff">for</font></b><font color="#ff0000"> i </font><font color="#F3E651">:=</font><font color="#ff0000"> </font><font color="#bb00ff">0</font><font color="#F3E651">;</font><font color="#ff0000"> i </font><font color="#F3E651"><</font><font color="#ff0000"> j</font><font color="#F3E651">;</font><font color="#ff0000"> i</font><font color="#F3E651">++</font><font color="#ff0000"> </font><font color="#F3E651">{</font> -<font color="#ff0000"> fmt</font><font color="#F3E651">.</font><font color="#7bc710">Fprintf</font><font color="#F3E651">(&</font><font color="#ff0000">sb</font><font color="#F3E651">,</font><font color="#ff0000"> </font><font color="#bb00ff">"%v "</font><font color="#F3E651">,</font><font color="#ff0000"> a</font><font color="#F3E651">[</font><font color="#ff0000">i</font><font color="#F3E651">])</font> -<font color="#ff0000"> </font><font color="#F3E651">}</font> - -<font color="#ff0000"> </font><b><font color="#ffffff">if</font></b><font color="#ff0000"> j </font><font color="#F3E651"><</font><font color="#ff0000"> l </font><font color="#F3E651">{</font> -<font color="#ff0000"> fmt</font><font color="#F3E651">.</font><font color="#7bc710">Fprintf</font><font color="#F3E651">(&</font><font color="#ff0000">sb</font><font color="#F3E651">,</font><font color="#ff0000"> </font><font color="#bb00ff">"... "</font><font color="#F3E651">)</font> -<font color="#ff0000"> </font><font color="#F3E651">}</font> - -<font color="#ff0000"> </font><b><font color="#ffffff">return</font></b><font color="#ff0000"> sb</font><font color="#F3E651">.</font><font color="#7bc710">String</font><font color="#F3E651">()</font> -<font color="#F3E651">}</font> -</pre> -<br /> -<span>The <span class='inlinecode'>Sorted</span> method checks whether the <span class='inlinecode'>ArrayList</span> is sorted. This will be used by the unit tests later on:</span><br /> -<br /> -<!-- Generator: GNU source-highlight 3.1.9 -by Lorenzo Bettini -http://www.lorenzobettini.it -http://www.gnu.org/software/src-highlite --> -<pre><b><font color="#ffffff">func</font></b><font color="#ff0000"> </font><font color="#F3E651">(</font><font color="#ff0000">a ArrayList</font><font color="#F3E651">[</font><font color="#ff0000">V</font><font color="#F3E651">])</font><font color="#ff0000"> </font><font color="#7bc710">Sorted</font><font color="#F3E651">()</font><font color="#ff0000"> </font><b><font color="#F35E1E">bool</font></b><font color="#ff0000"> </font><font color="#F3E651">{</font> -<font color="#ff0000"> </font><b><font color="#ffffff">for</font></b><font color="#ff0000"> i </font><font color="#F3E651">:=</font><font color="#ff0000"> </font><font color="#7bc710">len</font><font color="#F3E651">(</font><font color="#ff0000">a</font><font color="#F3E651">)</font><font color="#ff0000"> </font><font color="#F3E651">-</font><font color="#ff0000"> </font><font color="#bb00ff">1</font><font color="#F3E651">;</font><font color="#ff0000"> i </font><font color="#F3E651">></font><font color="#ff0000"> </font><font color="#bb00ff">0</font><font color="#F3E651">;</font><font color="#ff0000"> i</font><font color="#F3E651">--</font><font color="#ff0000"> </font><font color="#F3E651">{</font> -<font color="#ff0000"> </font><b><font color="#ffffff">if</font></b><font color="#ff0000"> a</font><font color="#F3E651">[</font><font color="#ff0000">i</font><font color="#F3E651">]</font><font color="#ff0000"> </font><font color="#F3E651"><</font><font color="#ff0000"> a</font><font color="#F3E651">[</font><font color="#ff0000">i</font><font color="#F3E651">-</font><font color="#bb00ff">1</font><font color="#F3E651">]</font><font color="#ff0000"> </font><font color="#F3E651">{</font> -<font color="#ff0000"> </font><b><font color="#ffffff">return</font></b><font color="#ff0000"> false</font> -<font color="#ff0000"> </font><font color="#F3E651">}</font> -<font color="#ff0000"> </font><font color="#F3E651">}</font> -<font color="#ff0000"> </font><b><font color="#ffffff">return</font></b><font color="#ff0000"> true</font> -<font color="#F3E651">}</font> -</pre> -<br /> -<span>And the last utility method used is <span class='inlinecode'>Swap</span>, which allows swapping the values of two indices in the <span class='inlinecode'>ArrayList</span>:</span><br /> -<br /> -<!-- Generator: GNU source-highlight 3.1.9 -by Lorenzo Bettini -http://www.lorenzobettini.it -http://www.gnu.org/software/src-highlite --> -<pre><b><font color="#ffffff">func</font></b><font color="#ff0000"> </font><font color="#F3E651">(</font><font color="#ff0000">a ArrayList</font><font color="#F3E651">[</font><font color="#ff0000">V</font><font color="#F3E651">])</font><font color="#ff0000"> </font><font color="#7bc710">Swap</font><font color="#F3E651">(</font><font color="#ff0000">i</font><font color="#F3E651">,</font><font color="#ff0000"> j int</font><font color="#F3E651">)</font><font color="#ff0000"> </font><font color="#F3E651">{</font> -<font color="#ff0000"> aux </font><font color="#F3E651">:=</font><font color="#ff0000"> a</font><font color="#F3E651">[</font><font color="#ff0000">i</font><font color="#F3E651">]</font> -<font color="#ff0000"> a</font><font color="#F3E651">[</font><font color="#ff0000">i</font><font color="#F3E651">]</font><font color="#ff0000"> </font><font color="#F3E651">=</font><font color="#ff0000"> a</font><font color="#F3E651">[</font><font color="#ff0000">j</font><font color="#F3E651">]</font> -<font color="#ff0000"> a</font><font color="#F3E651">[</font><font color="#ff0000">j</font><font color="#F3E651">]</font><font color="#ff0000"> </font><font color="#F3E651">=</font><font color="#ff0000"> aux</font> -<font color="#F3E651">}</font> - -</pre> -<br /> -<h2 style='display: inline' id='sleep-sort'>Sleep sort</h2><br /> -<br /> -<span>Let's implement our first algorithm, sleep sort. Sleep sort is a non-traditional and unconventional sorting algorithm based on the idea of waiting a certain amount of time corresponding to the value of each element in the input <span class='inlinecode'>ArrayList</span>. It's more of a fun, creative concept rather than an efficient or practical sorting technique. This is not a sorting algorithm you would use in any production code. As you can imagine, it is quite an inefficient sorting algorithm (it's only listed here as a warm-up exercise). This sorting method may also return false results depending on how the Goroutines are scheduled by the Go runtime. </span><br /> -<br /> -<br /> -<!-- Generator: GNU source-highlight 3.1.9 -by Lorenzo Bettini -ht |
