Method: MPFI::Vector#each_element_with_index

Defined in:
ext/mpfi_matrix/mpfi/ruby_mpfi_matrix.c

#each_element_with_indexObject Also known as: each_with_index

Evaluate block with each element and its index.



1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
# File 'ext/mpfi_matrix/mpfi/ruby_mpfi_matrix.c', line 1073

static VALUE r_mpfi_vector_each_element_with_index (VALUE self) {
  MPFIMatrix *ptr_self;
  VALUE ret;
  int i;
  RETURN_ENUMERATOR(self, 0, NULL);
  r_mpfi_get_matrix_struct(ptr_self, self);
  ret = Qnil;
  for (i = 0; i < ptr_self->size; i++) {
    volatile VALUE el = r_mpfi_make_new_fi_obj(ptr_self->data + i);
    ret = rb_yield(rb_ary_new3(2, el, INT2NUM(i)));
  }
  return ret;
}