-- Leo's gemini proxy

-- Connecting to warmedal.se:1965...

-- Connected

-- Sending request

-- Meta line: 20 text/gemini; lang=en

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


size(Disarray) returns a rough estimate of the number of elements it contains; a general ball park like "10", "100", "1000" or similar. It may also be an exact number, but rarely the actual number of elements.

insert(Disarray, Element, Index) inserts an element at or near the Index. How this index is calculated may vary, as the exact structure of the elements varies. Elements are never guaranteed to be unique in the Disarray, even if they've only been inserted once.

get(Disarray, Index) will return an element or list of elements at or near the Index. See the previous point about index calculation.

contains(Disarray, Element) will return a boolean indicating whether the Disarray contains an item Element. It's true if there's a relatively high probability of the Element being present, and false otherwise.

sort(Disarray) causes the Disarray to re-organize its structure. Synonyms for this method include 'resort', 'shuffle', 'disorganize', and 'pleaseGodMakeThisHaveSomeSortOfPredictableOrderForOnce'.

concatenate(Disarray, Disarray) combines the elements of two Disarrays. There is a small risk that some elements are lost along the way.


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 ew0k, 2021-02-16

-- Response ended

-- Page fetched on Sat May 4 16:59:55 2024