summaryrefslogtreecommitdiff
path: root/array.c
AgeCommit message (Collapse)Author
2016-04-22[DOC] Arrah#sum with non-numeric objects.akr
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54705 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-04-17* array.c (rb_ary_sum): [DOC] fix typos.ktsj
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54619 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-04-15* array.c (rb_ary_sum): Don't yield same element twice.akr
Found by nagachika. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54609 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-04-15* array.c (rb_ary_sum): Fix SEGV by [1/2r, 1].sum.akr
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54606 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-04-15rename rb_rational_add -> rb_rational_plusmrkn
* 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
2016-04-15array.c (rb_ary_sum): use rb_rational_add directlymrkn
* 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
2016-04-15array.c: sum for Rational and Float mixed arraysmrkn
* 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
2016-04-14[DOC]akr
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54578 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-04-14* array.c (rb_ary_sum): Support the optional argument, init, and block.akr
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54577 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-04-14[DOC]akr
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54568 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-04-13* array.c (rb_ary_sum): Array#sum is implemented.akr
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
2016-03-17* array.c, enum.c: make rdoc format consistent.mame
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54155 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-17* array.c (rb_ary_max, rb_ary_min): implement Array#max and min withmame
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
2016-03-17* array.c (rb_ary_max, rb_ary_min): implement a block by itself insteadmame
of delegating Enumerable#max/min. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54151 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2016-03-17* array.c (rb_ary_max, rb_ary_min): Array#max and Array#min added.mame
[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
2016-03-17* internal.c: struct cmp_opt_data added for refactoring out a datamame
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
2016-02-29array.c: [DOC] remove trailing comma [ci skip]nobu
* 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
2016-02-28Clarify set intersection and union documentationnobu
* 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
2016-01-27Fix a Ruby-Doc comment for Array#dignobu
* 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
2016-01-26array.c: reword [ci skip]nobu
* 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
2016-01-22RUBY_ASSERTnobu
* 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
2016-01-07* enum.c (enum_minmax): optimize object comparison inshugo
Enumerable#minmax. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53454 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-12-08* array.c: Improve and fix documentation for Array#digmarcandre
[#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
2015-11-20* array.c: clarify docs for take_while/drop_while samples.hsbt
[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
2015-11-17update rdoc of dig methods [ci skip]nobu
* 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
2015-11-09dignobu
* 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
2015-11-06* array.c: clarifies Array#reject! documentation.gogotanaka
[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
2015-10-29RUBY_DTRACE_CREATE_HOOKnobu
* 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
2015-10-22adjust spaces [ci skip]nobu
* 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
2015-09-28preserve encodings in error messagesnobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51962 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-09-15array.c: [DOC] correct Array#sort rdoc [ci skip]nobu
* 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
2015-09-15array.c: [DOC] correct Array#sort rdoc [ci skip]nobu
* 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
2015-08-11array.c: fix buffer sizenobu
* 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
2015-07-13remove needless volatilenobu
* 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
2015-07-05array.c: fix memory leaknobu
* 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
2015-06-21array.c: use ALLOCV_Nnobu
* 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
2015-06-12array.c: fix for enumeratornobu
* 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
2015-06-12array.c: typonobu
* 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
2015-06-12array.c: bsearch_indexnobu
* 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
2015-06-11array.c: fix array size overflownobu
* 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
2015-06-04* array.c: Revert r50763. because "reentered" is not typo.hsbt
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50767 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-06-04* array.c: fix a typo. Patch by @manish-shrivastavahsbt
[fix GH-922] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50763 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-05-15array.c: [DOC] return values are not new array [CI SKIP]nobu
* 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
2015-03-07* array.c: document that first element is kept when usinghsbt
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
2015-01-25array.c: reduce to_ary callnobu
* 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
2015-01-15array.c: linear performancenobu
* 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
2015-01-12* array.c (rb_ary_each): documented return value.hsbt
[misc #10469][ruby-core:66063] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49217 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-01-12array.c: trivial optimizationsnobu
* 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
2015-01-11array.c: class name encodingnobu
* 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
2015-01-10array.c: keep consistencynobu
* array.c (rb_ary_select_bang): keep the array consistent by removing unselected values soon. [ruby-dev:48805] [Bug #10722] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49196 b2dd03c8-39d4-4d8f-98ff-823fe69b080e