Singly-Linked List


Sometimes the overhead of larger containers isn't justifiable, and so the smaller node of the Singly-Linked List is advantageous.

This is also fundamentally how the Stack and Queue work, although this List has more overhead than either of those, but provides more features.

Notable Features

Non-Deallocative Traversal

Traversal between nodes of any list type does not remove the previous node, so they behave more like arrays.


Unlike the Stack or Queue, or the Array, nodes can be inserted inside the list without requiring a new list.


Some queries are possible upon this generalized list, and are made available here. Whether a list contains a value, all instances of a certain value, former N values, hinder N values, and so on. All of these queries either return a boolean or another list which can be queried.


Use of an iterator is slower than traversal through Node.Ahind, due to the implementation. This is because the list operations largely operate on nodes themselves, not on a cursor, so the cursor heavy iterator has additional overhead. Being simpler, iterators are good for prototyping or when performance doesn't matter, but manual traversal is advised.

As a compromise between iteration and traversal, an each function exists, which traverses through the list for you, constructing an array of the same ordering as the list, which can then be iterated through. The performance overhead is generally less than iteration, while otherwise working the same as iteration (all arrays work in iteration loops). Iterating over this in reverse is also the fastest approach to reverse order iteration through a singly-linked list, if this is occasionally needed. However for more regular need the Doubly-Linked List is recommended.