class BigArray(T)
- BigArray(T)
- Reference
- Object
Included Modules
- Indexable(T)
- Indexable::Mutable(T)
Defined in:
big_array.crConstant 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
- #+(other : BigArray(U)) : BigArray(T | U) forall U
- #<<(value : T) : self
-
#each_index(&) : Nil
Calls the given block once for each index in
self
, passing that index as a parameter. -
#size : Int64
Returns the number of elements in this container.
- #to_unsafe
-
#unsafe_fetch(index : Int)
Returns the element at the given index, without doing any bounds check.
-
#unsafe_put(index : Int, value : T)
Sets the element at the given index to value, without doing any bounds check.
Constructor Detail
Class Method Detail
Instance Method Detail
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 --
Returns the number of elements in this container.
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.
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.