#include "ruby.h" static inline VALUE ary_make_hash(ary1, ary2) VALUE ary1, ary2; { VALUE hash = rb_hash_new(); long i; for (i=0; i 10) { // Make a hash from the currently smallest version. // hash = ary_make_hash(result_array, 0); // Clear for use as temp array. // rb_ary_clear(result_array); // Get the current array. // current_array = rb_ary_entry(rb_array_of_arrays, i); // Iterate through all array elements. // for (j = 0; j < RARRAY_LEN(current_array); j++) { v = rb_ary_entry(current_array, j); if (rb_hash_delete(hash, v) != Qnil) { rb_ary_push(result_array, v); } } } else { // Make a new array from the currently smallest version. // ary = rb_ary_dup(result_array); // Clear for use as temp array. // rb_ary_clear(result_array); // Get the current array. // current_array = rb_ary_entry(rb_array_of_arrays, i); // Iterate through all array elements. // for (j = 0; j < RARRAY_LEN(current_array); j++) { v = rb_ary_entry(current_array, j); if (rb_ary_delete(ary, v) != Qnil) { rb_ary_push(result_array, v); } } } } return result_array; } VALUE p_mPerformant, p_cArray; void Init_picky() { p_mPerformant = rb_define_module("Performant"); p_cArray = rb_define_class_under(p_mPerformant, "Array", rb_cObject); rb_define_singleton_method(p_cArray, "memory_efficient_intersect", memory_efficient_intersect, 1); }