🍵️

2021-02-16

The Disarray Data Type

Virtually all programming languages have some sort of Array data type, though the implementations and interfaces of them vary. The basic idea is to structure data in a row, whereupon elements can be added (whether appended or inserted at a specific place), iterated over (or mapped), fetched, and so on and so forth. Anyways, this isn't about the Array.

Inspired by the state of the world today, and in the mood to be creative, I present to you: the Disarray.

The Disarray data type has similarities to the common Array, but only on the surface. It doesn't actually exist in any implementation that I know of yet. Consider this a specification, or a language agnostic interface description.

Constructor

You may initiate a Disarray empty, or with a set or list of initial elements. The Disarray will organize the elements as a set, heap, stack, list, tree, or a combination thereof. It will often re-organize it at random intervals and for no apparent reason during execution.

Functions/Methods

Iteration

The Disarray is iterable. You may iterate over its elements, and be somewhat certain that all elements have been represented at least once in the iteration. The order of the elements vary between iterations, even if no other function has been applied to the Disarray between them. If the iteration terminates before all elements have been represented, you will most likely not really know. If the iteration continues even after all elements have been represented at least once the Disarray may start returning null values, or re-use elements. Sometimes it returns a list or set of elements at once when iterating.

-- CC0 Björn Wärmedal