Class: Yadriggy::C::IntArray
Overview
Array of 32bit integers.
In C, the type of this array is arrayof(Int)
.
Class Method Summary collapse
Instance Method Summary collapse
- #[](index) ⇒ Object
- #[]=(index, value) ⇒ Object
-
#initialize(size, ptr = nil) ⇒ IntArray
constructor
A new instance of IntArray.
Methods inherited from FFIArray
#==, #length, #memory_pointer, #set_values, #size, #to_a
Constructor Details
#initialize(size, ptr = nil) ⇒ IntArray
Returns a new instance of IntArray.
56 57 58 59 60 61 62 |
# File 'lib/yadriggy/c/ffi.rb', line 56 def initialize(size, ptr=nil) if ptr.nil? @array = FFI::MemoryPointer.new(:int32, size) else @array = ptr end end |
Class Method Details
.element_type ⇒ Object
72 73 74 |
# File 'lib/yadriggy/c/ffi.rb', line 72 def self.element_type() Integer end |
Instance Method Details
#[](index) ⇒ Object
64 65 66 |
# File 'lib/yadriggy/c/ffi.rb', line 64 def [](index) @array.get_int32(index * 4) end |
#[]=(index, value) ⇒ Object
68 69 70 |
# File 'lib/yadriggy/c/ffi.rb', line 68 def []=(index, value) @array.put_int32(index * 4, value) end |