module Indexable(T)

Overview

A container that allows accessing elements via a numeric index.

Indexing starts at 0. A negative index is assumed to be relative to the end of the container: -1 indicates the last element, -2 is the next to last element, and so on.

Types including this module are typically Array-like types.

Stability guarantees

Several methods in Indexable, such as #bsearch and #cartesian_product, require the collection to be stable; that is, calling #each(&) over and over again should always yield the same elements, provided the collection is not mutated between the calls. In particular, #each(&) itself should not mutate the collection throughout the loop. Stability of an Indexable is guaranteed if the following criteria are met:

The standard library assumes that all including types of Indexable are always stable. It is undefined behavior to implement an Indexable that is not stable or only conditionally stable.

Included Modules

Defined in:

debug/to_debug/indexable.cr

Instance Method Summary

Instance Method Detail

def to_debug(io) : Nil #

[View source]