diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-02-03 05:34:16 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2003-02-03 05:34:16 +0000 |
commit | 0c90036fd14fd5aef136afccfb38e42c4d3c01e3 (patch) | |
tree | b7b065aabe639d272c8e53defbe59daac51bbf23 /array.c | |
parent | e58e5cb5caf8aeac402ebe2db617c20beca2c0eb (diff) |
* re.c (rb_memsearch): algolithm body of String#index.
* error.c (Init_Exception): "to_str" removed.
* eval.c (eval): should not rely on Exception#to_str
* eval.c (compile_error): ditto.
* error.c (err_append): ditto.
* hash.c (rb_hash_merge): Hash#merge, non destructive "update".
now there's also Hash#merge! which is an alias to "update".
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3431 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'array.c')
-rw-r--r-- | array.c | 34 |
1 files changed, 17 insertions, 17 deletions
@@ -1649,23 +1649,6 @@ rb_ary_cmp(ary1, ary2) } static VALUE -rb_ary_diff(ary1, ary2) - VALUE ary1, ary2; -{ - VALUE ary3; - long i; - - ary2 = to_ary(ary2); - ary3 = rb_ary_new(); - for (i=0; i<RARRAY(ary1)->len; i++) { - if (rb_ary_includes(ary2, RARRAY(ary1)->ptr[i])) continue; - if (rb_ary_includes(ary3, RARRAY(ary1)->ptr[i])) continue; - rb_ary_push(ary3, RARRAY(ary1)->ptr[i]); - } - return ary3; -} - -static VALUE ary_make_hash(ary1, ary2) VALUE ary1, ary2; { @@ -1684,6 +1667,23 @@ ary_make_hash(ary1, ary2) } static VALUE +rb_ary_diff(ary1, ary2) + VALUE ary1, ary2; +{ + VALUE ary3, hash; + long i; + + hash = ary_make_hash(to_ary(ary2), 0); + ary3 = rb_ary_new(); + + for (i=0; i<RARRAY(ary1)->len; i++) { + if (st_lookup(RHASH(hash)->tbl, RARRAY(ary1)->ptr[i], 0)) continue; + rb_ary_push(ary3, RARRAY(ary1)->ptr[i]); + } + return ary3; +} + +static VALUE rb_ary_and(ary1, ary2) VALUE ary1, ary2; { |