Skip to content
Derk Norton edited this page May 28, 2024 · 11 revisions

Overview

Higher level programming tasks often involve sequences of values. This framework provides a simple set of Go based collection types that can be used to address these needs. The collection types are more intuitive and easier to use than the low level native Go array, slice and map types; although the framework does add the relevant collection interfaces to the native Go types making them easier to use as well. The framework also generate a canonically formatted string for each type of collection making logging and debugging easier.

Sequence

Each collection type allows the traversal of the values maintained by the collection.

Ordinal Based Indices

One could argue that cardinal (quantitative: 0, 1, 2, etc.) based indices might possibly have made sense 70 years ago when assembly languages were mapping directly to memory locations that included index offset amounts. We would argue, however, that even back then for programming languages it would have made more sense to use ordinal (position: "first", "second", etc.) based indices and reserved the value 0 for an invalid index instead of -1. Alas, that is all "water under the bridge" as they say...

Regardless of where you stand on this debate, we think you will find our approach to indices very intuitive and easy to use.

Indices

The various interfaces for the collection types provided by this framework support both positive and negative indices. And since they are ordinal based indices, the positive and negative indices are symmetrical. You can use an index of 1 to access the first value in a sequence and -1 to access the last value. The values can also be accessed sequentially using an Iterator.

Choosing a Collection Type

In general, for most higher level programming tasks, the collections in this framework should be used instead of the native Go arrays/slices and maps. The following flowchart helps you determine which collection type will best suit your needs.

Flow Chart

To view the details of a particular collection type, click on links listed in the side bar in the upper right corner ↗️ of this page.

Clone this wiki locally