aboutsummaryrefslogtreecommitdiffstats
path: root/array.c
Commit message (Collapse)AuthorAgeFilesLines
* Fix rb_ary_sum for mathnmrkn2016-05-011-4/+18
| | | | | | | | * array.c (rb_ary_sum): fix for mathn * test/ruby/test_array.rb (test_sum): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54870 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* [DOC] Arrah#sum with non-numeric objects.akr2016-04-221-1/+13
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54705 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * array.c (rb_ary_sum): [DOC] fix typos.ktsj2016-04-171-2/+2
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54619 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * array.c (rb_ary_sum): Don't yield same element twice.akr2016-04-151-0/+4
| | | | | | | | Found by nagachika. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54609 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * array.c (rb_ary_sum): Fix SEGV by [1/2r, 1].sum.akr2016-04-151-18/+14
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54606 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* rename rb_rational_add -> rb_rational_plusmrkn2016-04-151-1/+1
| | | | | | | | | | | * rational.c (rb_rational_plus): rename from rb_rational_add to be aligned with rb_fix_plus. * array.c (rb_ary_sum): ditto. * internal.h: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54603 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* array.c (rb_ary_sum): use rb_rational_add directlymrkn2016-04-151-1/+1
| | | | | | | | | | | * rational.c (rb_rational_add): rename from nurat_add. * array.c (rb_ary_sum): use rb_rational_add directly. * test/ruby/test_array.rb (test_sum): add assertions for an array of Rational values. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54602 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* array.c: sum for Rational and Float mixed arraysmrkn2016-04-151-0/+18
| | | | | | | | | | * array.c (rb_ary_sum): apply the precision compensated algorithm for an array in which Rational and Float values are mixed. * test/ruby/test_array.rb (test_sum): add assertions for the above change. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54601 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* [DOC]akr2016-04-141-1/+5
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54578 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * array.c (rb_ary_sum): Support the optional argument, init, and block.akr2016-04-141-15/+32
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54577 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* [DOC]akr2016-04-141-3/+4
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54568 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * array.c (rb_ary_sum): Array#sum is implemented.akr2016-04-131-0/+87
| | | | | | | | | | | | | Kahan's compensated summation algorithm for precise sum of float numbers is moved from ary_inject_op in enum.c. * enum.c (ary_inject_op): Don't specialize for float numbers. [ruby-core:74569] [Feature#12217] proposed by mrkn. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54565 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * array.c, enum.c: make rdoc format consistent.mame2016-03-171-4/+4
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54155 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * array.c (rb_ary_max, rb_ary_min): implement Array#max and min withmame2016-03-171-2/+2
| | | | | | | | | | arguments. replace super call with rb_nmin_run. * enum.c (nmin_run): exported (as rb_nmin_run). * internal.h: added a prototype for rb_nmin_run. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54152 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * array.c (rb_ary_max, rb_ary_min): implement a block by itself insteadmame2016-03-171-12/+32
| | | | | | of delegating Enumerable#max/min. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54151 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * array.c (rb_ary_max, rb_ary_min): Array#max and Array#min added.mame2016-03-171-0/+93
| | | | | | | | | | | | | | | [Feature #12172] * internal.h (OPTIMIZED_CMP): moved from enum.c so that array.c can use it. * test/ruby/test_array.rb (test_max, test_min): tests for Array#max and Array#min. * test/ruby/test_enum.rb (test_max, test_min): revised a bit to test Enumerable#max and #min explicitly. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54150 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * internal.c: struct cmp_opt_data added for refactoring out a datamame2016-03-171-6/+5
| | | | | | | | | | structure for CMP_OPTIMIZABLE * array.c (struct ary_sort_data): use struct cmp_opt_data. * enum.c (struct min_t, max_t, min_max_t): use struct cmp_opt_data. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54149 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* array.c: [DOC] remove trailing comma [ci skip]nobu2016-02-291-1/+1
| | | | | | | | * array.c (rb_ary_push_m): [DOC] Remove trailing comma from Array#push example, as other Array examples doesn't put trailing comma. [Fix GH-1279] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53970 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Clarify set intersection and union documentationnobu2016-02-281-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | * array.c (rb_ary_and): clarify that set intersection returns the unique elements common to both arrays. * array.c (rb_ary_or): clarify that union preserves the order from the given arrays. - Most know what intersection means, but saying the operation excludes duplicates could be misleading ([1] & [1], duplicates excluded, might mean a result of []). - Instead, saying intersection returns the unique elements common to both arrays is more concise and less ambiguous. - The set union's documentation was incomplete in its describing preservation of order. Saying union preserves the order of the original array neglects the idea that the order of the elements in both arrays, as given, will be preserved. - Instead, saying set union preserves the order from the given arrays (and adding an example) fully demonstrates the idea. [Fix GH-1273] [ci skip] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53958 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Fix a Ruby-Doc comment for Array#dignobu2016-01-271-1/+1
| | | | | | | | * array.c (rb_ary_dig): [DOC] fix the exception class to be raised when intermediate object does not have dig method. TypeError will be raised now. [Fix GH-1224] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53666 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* array.c: reword [ci skip]nobu2016-01-261-4/+4
| | | | | | | * array.c (permute0, rpermute0): [DOC] Substitute indexes -> indices in documentation for consistency. [Fix GH-1222] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53660 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* RUBY_ASSERTnobu2016-01-221-1/+1
| | | | | | | * error.c (rb_assert_failure): assertion with stack dump. * ruby_assert.h (RUBY_ASSERT): new header for the assertion. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53615 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * enum.c (enum_minmax): optimize object comparison inshugo2016-01-071-18/+2
| | | | | | Enumerable#minmax. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53454 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * array.c: Improve and fix documentation for Array#digmarcandre2015-12-081-3/+6
| | | | | | | | | | | | [#11776] * hash.c: ditto * struct.c: ditto * test_hash.rb: Add basic test for user defined `dig`. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52941 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * array.c: clarify docs for take_while/drop_while samples.hsbt2015-11-201-2/+2
| | | | | | [ci skip][fix GH-1028] Patch by @leriksen git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52680 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* update rdoc of dig methods [ci skip]nobu2015-11-171-2/+2
| | | | | | | | * array.c (rb_ary_dig), hash.c (rb_hash_dig): [DOC] Update comments describing dig methods. [Fix GH-1103] * struct.c (rb_struct_dig): [DOC] add rdoc. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52607 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* dignobu2015-11-091-1/+25
| | | | | | | | | * array.c (rb_ary_dig): new method Array#dig. * hash.c (rb_hash_dig): new method Hash#dig. * object.c (rb_obj_dig): dig in nested arrays/hashes. [Feature #11643] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52504 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * array.c: clarifies Array#reject! documentation.gogotanaka2015-11-061-2/+2
| | | | | | [fix GH-894][ci skip] Patch by @GxSplinter git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52468 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* RUBY_DTRACE_CREATE_HOOKnobu2015-10-291-7/+2
| | | | | | | | | | * internal.h (RUBY_DTRACE_CREATE_HOOK): macro to call hook at object creation. * vm.c (rb_source_location, rb_source_loc): retrieve source path and line number at once. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52340 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* adjust spaces [ci skip]nobu2015-10-221-3/+3
| | | | | | | * array.c (rb_ary_collect): [DOC] Fix space of code example of Array#map. [Fix GH-1062] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52224 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* preserve encodings in error messagesnobu2015-09-281-3/+4
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51962 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* array.c: [DOC] correct Array#sort rdoc [ci skip]nobu2015-09-151-4/+4
| | | | | | | | * array.c (rb_ary_sort_bang, rb_ary_sort): [DOC] correct block return values, which may be a negative or positive integer, not ony -1 or +1. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51860 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* array.c: [DOC] correct Array#sort rdoc [ci skip]nobu2015-09-151-6/+6
| | | | | | | | * array.c (rb_ary_sort_bang, rb_ary_sort): [DOC] Correct description of array sort block return values. And also fix up the grammar a bit. [Fix GH-1020] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51859 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* array.c: fix buffer sizenobu2015-08-111-1/+1
| | | | | | | * array.c (rb_ary_repeated_permutation): fix buffer size, ALLOCV_N already multiplies element size. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51532 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* remove needless volatilenobu2015-07-131-2/+1
| | | | | | | | | * array.c (rb_ary_each): remove needless volatile for outdated clang 3.0. revert r32201. * cont.c (cont_capture): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51227 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* array.c: fix memory leaknobu2015-07-051-1/+1
| | | | | | | | | * array.c (rb_ary_sort_bang): the original array may not be embedded even if a substitution array is embedded, as it is embedded when the original array is short enough but not embedded. [ruby-dev:49166] [Bug #11332] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51147 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* array.c: use ALLOCV_Nnobu2015-06-211-1/+1
| | | | | | * array.c (rb_ary_permutation): use ALLOCV_N instead of ALLOCV. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50987 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* array.c: fix for enumeratornobu2015-06-121-16/+10
| | | | | | | * array.c (rb_ary_bsearch_index): fix function typt to return enumerator if no block given. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50844 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* array.c: typonobu2015-06-121-1/+1
| | | | | | * array.c (rb_ary_bsearch_index): fix typo. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50841 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* array.c: bsearch_indexnobu2015-06-121-6/+40
| | | | | | | | * array.c (rb_ary_bsearch_index): Implement Array#bsearch_index method, which is similar to bsearch and returns the index or nil. [Feature #10730] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50839 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* array.c: fix array size overflownobu2015-06-111-1/+12
| | | | | | | | | * array.c (ary_ensure_room_for_push): check if array size will exceed maxmum size to get rid of buffer overflow. [ruby-dev:49043] [Bug #11235] * array.c (ary_ensure_room_for_unshift, rb_ary_splice): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50827 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * array.c: Revert r50763. because "reentered" is not typo.hsbt2015-06-041-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50767 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * array.c: fix a typo. Patch by @manish-shrivastavahsbt2015-06-041-1/+1
| | | | | | [fix GH-922] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50763 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* array.c: [DOC] return values are not new array [CI SKIP]nobu2015-05-151-2/+2
| | | | | | | | * array.c (rb_ary_assoc, rb_ary_rassoc): [DOC] the result when key was found is the existing element, not a new array. reported by Giau Nguyen <giaunv AT nustechnology.com>. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50501 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * array.c: document that first element is kept when usinghsbt2015-03-071-0/+4
| | | | | | | Array#uniq and #uniq! [fix GH-845][ci skip] Patch by @riffraff git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49879 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* array.c: reduce to_ary callnobu2015-01-251-1/+5
| | | | | | | * array.c (flatten): no need to call to_ary method on elements beyond the given level. [ruby-core:67637] [Bug #10748] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49400 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* array.c: linear performancenobu2015-01-151-28/+72
| | | | | | | * array.c (rb_ary_select_bang, ary_reject_bang): linear performance. [ruby-core:67418] [Feature #10714] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49255 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * array.c (rb_ary_each): documented return value.hsbt2015-01-121-2/+2
| | | | | | [misc #10469][ruby-core:66063] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49217 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* array.c: trivial optimizationsnobu2015-01-121-9/+7
| | | | | | | * array.c (rb_ary_bsearch): trivial optimizations, for Fixnum, and by keeping the last satisfied element. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49216 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* array.c: class name encodingnobu2015-01-111-6/+6
| | | | | | | * array.c (rb_ary_bsearch): preserve encoding of class name in an exception message. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49215 b2dd03c8-39d4-4d8f-98ff-823fe69b080e