class BigArray(T)

Included Modules

Defined in:

big_array.cr

Constant Summary

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

Class Method Summary

Instance Method Summary

Constructor Detail

def self.new(initial_capacity capacity : Int64 = 0) #

[View source]

Class Method Detail

def self.build(capacity : Int64, &) #

[View source]

Instance Method Detail

def +(other : BigArray(U)) : BigArray(T | U) forall U #

[View source]
def <<(value : T) : self #

[View source]
def each_index(&) : Nil #
Description copied from module Indexable(T)

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 --

[View source]
def size : Int64 #
Description copied from module Indexable(T)

Returns the number of elements in this container.


[View source]
def to_unsafe #

[View source]
def unsafe_fetch(index : Int) #
Description copied from module Indexable(T)

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.


[View source]
def unsafe_put(index : Int, value : T) #
Description copied from module Indexable::Mutable(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.


[View source]