class

BigArray(T)

Inherits Indexable::Mutable < Indexable < Enumerable < Iterable < Indexable < Enumerable < Iterable < Reference < Object

Constants

MIN_CAPACITY = 8_i64

The minimum capacity of a buffer to allocate

RESIZE_COEFFICIENT = 1.5

How much to resize by each time the

Constructors

new(initial_capacity capacity : Int64 = 0)
Source

Class methods

build(capacity : Int64, &)
Source

Instance methods

+(other : BigArray(U)) : BigArray(T | U) forall U
Source
<<(value : T) : self
Source
each_index

Calls the given block once for each index in self, passing that index as a parameter.

a = ["a", "b", "c"]
a.each_index { |x| print x, " -- " }

produces:

0 -- 1 -- 2 --
Source
size

Returns the number of elements in this container.

Source
to_unsafe
Source
unsafe_fetch(index : Int)

Returns the element at the given index, without doing any bounds check.

Indexable makes sure to invoke this method with index in 0...size, so converting negative indices to positive ones is not needed here.

Clients never invoke this method directly. Instead, they access elements with #[](index) and #[]?(index).

This method should only be directly invoked if you are absolutely sure the index is in bounds, to avoid a bounds check for a small boost of performance.

Source
unsafe_put(index : Int, value : T)

Sets the element at the given index to value, without doing any bounds check.

Indexable::Mutable makes sure to invoke this method with index in 0...size, so converting negative indices to positive ones is not needed here.

Clients never invoke this method directly. Instead, they modify elements with #[]=(index, value).

This method should only be directly invoked if you are absolutely sure the index is in bounds, to avoid a bounds check for a small boost of performance.

Source