> [!info]- Article PGP Signature > > To verify this signature, use the public key on the [[Hello, World!|Home Page]] and follow the instructions linked there. > > ``` > -----BEGIN PGP SIGNATURE----- > -----END PGP SIGNATURE----- > ``` > ## Today's Topics: Linked Lists & Blog Commitments ##### August 29th, 2025, ca. 11:00 -0400 --- ### Contributions - PR: [c3lang#2438](https://github.com/c3lang/c3c/pull/2438) ### The `LinkedList` Collection (in C3) The [Linked List]() construct is perhaps one of the simplest to wrap one's head around when learning about data structures and algorithms. It's essentially a series of dynamically-allocated (read: `malloc`'d) "nodes" which contain -- at a _minimum_ -- both a `value`, the underlying data, and a `next` pointer, which points to the next node in the list. This is very useful to employ when you're unsure of the final size of an array at runtime and don't want to create a strict _bound_, or size limit, on your collection of data. > [!tip] Everyone Starts Somewhere > > When I was really starting to grok _and apply_ fundamental computer science concepts, I wrote a library called [yallic](https://github.com/NotsoanoNimus/yallic), which is an acronym for _Yet Another Linked List in C_. > > **Fair warning** if you click: this is really fundamental stuff gone mostly awry -- I could have made it much better, and that's the issue with implementing certain data structures when you're just starting to understand the concepts. > > Nothing wrong with trying new data structures/algorithms out, but you *really shouldn't* incorporate these types of things in your projects without full confidence of their efficiency! Anyway, there are a few different types of linked lists: > [!info]+ Types of Linked Lists... > ###### Singly-Linked List > A [**singly-linked list**](https://en.wikipedia.org/wiki/Linked_list#Singly_linked_list) is a one-way linked list, where all nodes around chained with a `next` pointer and no `prev` or `last` pointer. This means that if you were, for example, wanting to find the last item in the list (in order to add onto it), you would have to traverse the list to its tail element in order to modify that node. \[_NOTE_, that's not necessary true if the linked-list structure maintains the `last` node pointer in its structure.\] > > ###### Doubly-Linked List > A [**doubly-linked list**](https://en.wikipedia.org/wiki/Linked_list#Doubly_linked_list) is a two-way linked list, where nodes are chained together with both a `next` pointer, to get the next sequential node, and a `prev` or `last` pointer, to get the previous node. > > ###### Circular Linked List > A [**circular linked-list**](https://en.wikipedia.org/wiki/Linked_list#Circular_linked_list) can be either singly- or doubly- linked as well. The distinction this type of linked list has from the linear ones is that the final node's `next` pointer points back to the *head*, or front, of the linked list. In a _circular doubly-linked list_, the *head* node will also have a `prev` pointer that points to the *tail* of the linked list. > > --- > **Congrats!** You are now well-versed *(I never said an `expert` ;) )* on what there is to know about the linked list abstraction. --- ##### Soooo... C3? Ah yes, so the C3 changes from [this PR](https://github.com/c3lang/c3c/pull/2438) updates simply made the `LinkedList` collection type iterable with `foreach` and elements accessible with the `[]` operator. Using `foreach` / `foreach_r`: ```swift // before - this returns a copy and not a reference for (usz i = 0; i < list.len(); ++i) { some_op(list.get(i)); } // after - dereferencing here is optional, but if `some_op` would // ideally operate on a reference of the element, you may. foreach (&e : list) some_op(*e); foreach (e : list) some_op(e); // same thing ``` However, I didn't exactly do this the right way. C3's `foreach` gets by well with the array indexing and length operators. **BUT** it's better to have used an iterator instead so that `foreach` and `foreach_r`, the reverse orientation, can know the most efficient way to traverse the linked list with `O(1)` speeds. What I find pretty fun about this update is that the `LinkedList` is now incorporated (_and tested!_) with my [[2025-08-15 - Zip!|array zip changes]], as well as [[2025-08-18 - @reduce and @filter|the others]] (`@reduce`, `@filter`, etc.). I just need to make them more efficient to use. :) In my next work log, I'll probably add a brief snippet about how I added this `iterator` to make `foreach` perform much faster. --- ### Altering my Commitment This coming Fall I'm primed and ready to be an adjunct professor at two separate post-secondary institutions. This is brand-new to me, since I only acquired my Master's degree last year. Accompanying this change in title comes a bit of a change in how I will commit to writing my articles and content for this site. The first change is--you guessed it--**no more daily articles**. I simply can't keep up with everything else going on, and that's only going to get more difficult. With that being said, you can expect the _quality_ of the content I do blog about (==weekly or semi-weekly==) to improve dramatically. I won't be cutting corners to save time (not that I did that too much already). The second change is that I'd like to start writing my more "official" articles for this site, not just the daily work logs, which are mostly zoomed into C3 stuff right now. This means I want to actually create full and detailed documents that talk about all the SHA-3 and other cryptography concepts I've learned about. The hope is that posting the titled and "official" articles aggregates my experiences and **makes it easier for visitors** to land on pages they want to see, rather than combing through a forest of daily work logs and vague blog-post titles they're not interested in. With these two changes, I'm making a commitment for the site to be better all around: both for myself and its visitors. After all, I am paying for this. :) Now that I've finally typed it all out, I'm going to saunter into the extended vacation weekend (it's **Labor Day** in the U.S. on Monday), do some recreational programming if I feel like it, and spend some time with friends and family for this last hurrah of Summer. Additionally, I'm leaving for a ==two-week-ish hiatus== for a long vacation starting Thursday. You can ***expect the blog to be silent*** for those weeks while I'm gone. Thanks for reading!