summaryrefslogtreecommitdiff
path: root/enumerator.c
AgeCommit message (Collapse)Author
2019-08-13* expand tabs.git
2019-08-13Add compaction callbacks for EnumeratorAaron Patterson
This commit gives Enumerator compaction support
2019-08-01Use predefined idTo_procNobuyoshi Nakada
2019-06-21Remove duplicate functionsNobuyoshi Nakada
2019-06-21* expand tabs.git
2019-06-21Enumerator::Lazy should support filter_mapShugo Maeda
Fixes [Bug #15949]
2019-06-21Fix an example [ci skip]Nobuyoshi Nakada
2019-06-21Fix call-seq of lazy.filter_map [ci skip]Kazuhiro NISHIYAMA
2019-06-21* expand tabs.git
2019-06-21Lazy filter_mapNobuyoshi Nakada
2019-05-18[DOC] Improve documentation for Enumerator::LazyMarcus Stollsteimer
2019-05-14Static symbols can't be moved (they are not RValue)Aaron Patterson
This is my mistake, I thought they were regular objects, but apparently they are not. We don't need to pin them. Revert "Symbols can move so only cache IDs" This reverts commit 672ee5f6ed5a6840a3be9150b6721a5ee8f8766b.
2019-05-14Symbols can move so only cache IDsAaron Patterson
IDs can't move, we need to use them to look up the symbol objects later.
2019-04-27Add `or nil` to call-seq of `Enumerator::ArithmeticSequence#begin`Kazuhiro NISHIYAMA
``` % ruby -ve 'p (nil..).first' ruby 2.6.3p62 (2019-04-16 revision 67580) [x86_64-darwin18] nil % ruby -ve 'p (nil..).begin' ruby 2.6.3p62 (2019-04-16 revision 67580) [x86_64-darwin18] nil ```
2019-04-08enumerator.c: force hash values fixablenobu
* enumerator.c (arith_seq_hash): force hash values fixable on LLP64 environment. [ruby-core:92190] [Bug #15755] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67466 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-04-04enumerator.c: make arith_seq_first support nil beginmrkn
* enumerator.c: (arith_seq_first): support nil begin. * test/ruby/test_arithmetic_sequence.rb (test_first): add assertions for beginless and endless arithmetic sequences. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67435 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-03-20Add Enumerator::Lazy docs.hsbt
* explanation of the class concept, with examples; * docs for all class methods (most of them just say "Like Enumerable#<methodname>, but chains operation to be lazy-evaluated.", but I believe they are useful this way because now have proper call-sequences and link to corresponding Enumerable's explanations) * simplified example for ::new to emphasize the main concept * Enumerable#lazy docs are slightly lightened and linked to this class for more in-depth explanations. [Misc #15529][ruby-core:91046] Co-authored-by: zverok <zverok.offline@gmail.com> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67320 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-03-11Implement Enumerator::Yielder#to_procknu
A Yielder object can now be directly passed to another method as a block argument. ```ruby enum = Enumerator.new { |y| Dir.glob("*.rb") { |file| File.open(file) { |f| f.each_line(&y) } } } ``` git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67211 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-01-30* expand tabs.svn
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66948 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-01-30enumerator.c: fix arith_seq_first for Infinitymrkn
* enumerator.c (arith_seq_first): fix for Float::INFINITY. * test/ruby/test_arithmetic_sequence.rb: add tests. * numeric.c (ruby_float_step_size): export for internal use. * internal.h: add prototype declaration of ruby_float_step_size. [ruby-core:90937][Bug #15518] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66947 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-24enumerator.c: fix inspect with the last empty hashnobu
[ruby-core:90685] [Bug #15455] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66519 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-21range.c: reject ArithmeticSequence in rb_range_valuesmrkn
Reject ArithmeticSequence in rb_range_values so that methods like Array#[] raises TypeError for ArithmeticSequence as an index. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66478 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-21enumerator.c: Fix airth_seq_each for Rationalmrkn
Fix the wrong uses of rb_int_ge in arith_seq_each. [ruby-core:90648] [Bug #15444] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66474 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-12enumerator.c: Add rb_arithmetic_sequence_components_tmrkn
Add rb_arithmetic_sequence_components_t struct for encapsulating the components of ArithmeticSequence. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66353 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-12enumerator.c: rb_arithmetic_sequence_extractmrkn
New public C-API for extracting components of Enumerator::ArithmeticSequence or Range. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66351 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-06Prefer rb_check_arity when 0 or 1 argumentsnobu
Especially over checking argc then calling rb_scan_args just to raise an ArgumentError. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66238 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-03use RARRAY_AREF instead of RARRAY_PTR_USE.ko1
* enumerator.c (enum_chain_total_size): use RARRAY_AREF instead of RARRAY_PTR_USE because we don't need non-const ptr. * enumerator.c (enum_chain_each): ditto. * enumerator.c (enum_chain_rewind): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66148 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-27Add Float::INFINITY or nil to call-seq of Enumerator::Chain#size [ci skip]kazu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66051 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-27enumerator.c (enum_chain_yield_block): use predefined IDnormal
No point in having rb_intern lookup and cache a predefined ID git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66050 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-24Implement Enumerator#+ and Enumerable#chain [Feature #15144]knu
They return an Enumerator::Chain object which is a subclass of Enumerator, which represents a chain of enumerables that works as a single enumerator. ```ruby e = (1..3).chain([4, 5]) e.to_a #=> [1, 2, 3, 4, 5] e = (1..3).each + [4, 5] e.to_a #=> [1, 2, 3, 4, 5] ``` git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65949 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-16avoid division by zeroshyouhei
* cvt(): use signbit() instead of 1/d < 0 * w_float(): ditto * ruby_float_step_size(): unit==0 check shall be prior to divisions * arith_seq_float_step_size(): ditto * rb_big_divide(): same as r65642 * fix_divide(): ditto * rb_big_fdiv_double(): ditto * fix_fdiv_double(): ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65751 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-22* expand tabs.svn
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65303 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-22Set the size of a new enumerator created by Enumerator#each with arguments ↵knu
to nil When each() takes arguments, it is never safe to assume that the iteration would repeat the same number of times as with each() without any argument. Actually, there is no way to get the exact number, so the size should be set to nil to denote that. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65302 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-10-12enumerator.c: [DOC] small fixstomar
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65042 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-09-18Lazy Enumerator reduce intermediate array creationnobu
[ruby-core:87907] [Bug #14908] [Fix GH-1912] From: Anmol Chopra <chopraanmol1@gmail.com> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64770 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-09-12[DOC] aseq.each always return self [ci skip]kazu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64701 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-09-12[DOC] Add the documentation of ArithmeticSequencemrkn
[ci-skip] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64696 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-09-12enumerator.c: Fix ArithmeticSequence for complex stepmrkn
Make sure Enumerator::ArithmeticSequence#each to work well for a complex step value. This reverts commit ca47fb329a1d48af3e1009620bdb18e931c9f188. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64695 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-09-12Revert "enumerator.c: Fix ArithmeticSequence for complex step"mrkn
This reverts commit 0a0f8238d02a2dfff4cd2892408e14cb826cec7e. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64693 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-09-12enumerator.c: Fix ArithmeticSequence for complex stepmrkn
Make sure Enumerator::ArithmeticSequence#each to work well for a complex step value. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64692 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-09-05enumerator.c: [DOC] Enumerator::Lazy#force [ci skip]nobu
added documentation of Enumerator::Lazy#force, just to clarify that it is an alias of an inherited method. [ruby-core:88872] [Bug #15079] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64645 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-08-20Remove extra semicolonkazu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64480 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-08-16Adding Enumerator::Lazy#uniq and Enumerator::Lazy#grep_v to proc chainingnobu
[Feature #14994] [Fix GH-1930] From: Anmol Chopra <chopraanmol1@gmail.com> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64385 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-08-16enumerator.c: id_lazy is no longer used since r38923nobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64384 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-08-10enumerator.c: fix for non-integral argument for ArithmeticSequence#lastmrkn
This fixes a bug of Enumerator::ArithmeticSequence#last in the case that a non-integral argument is passed. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64262 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-08-09enumerator.c: undef new and allocate of ArithmeticSequencemrkn
Undefine new and allocate methods of Enumerator::ArithmeticSequence. [ruby-core:82816] [Feature #13904] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64256 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-08-06enumerator.c: Introduce Enumerator::ArithmeticSequencemrkn
This commit introduces new core class Enumerator::ArithmeticSequence. Enumerator::ArithmeticSequence is a subclass of Enumerator, and represents a number generator of an arithmetic sequence. After this commit, Numeric#step and Range#step without blocks returned an ArithmeticSequence object instead of an Enumerator. This class introduces the following incompatibilities: - You can create a zero-step ArithmeticSequence, and its size is not ArgumentError, but Infinity. - You can create a negative-step ArithmeticSequence from a range. [ruby-core:82816] [Feature #13904] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@64205 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-03-15enumerator.c: pretty kwagsnobu
* enumerator.c (append_method): pretty format for keyword arguments. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62755 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-03-13Bug Fix Enumerator::Lazy#uniq state for multiple callnobu
* enumerator.c (lazy_uniq_i): create new hash for each calls. [Fix GH-1820] Currently 2.5.0-preview1 :001 > arr = (0..100).lazy.uniq{|i| i % 10} => #<Enumerator::Lazy: #<Enumerator::Lazy: 0..100>:uniq> 2.5.0-preview1 :002 > arr.to_a => [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] 2.5.0-preview1 :003 > arr.to_a => [] Expected arr.to_a to always return same output From: Anmol Chopra <anmolchopra@rocketbox.in> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62731 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-02-25Add a new #filter alias for #selecteregon
* In Enumerable, Enumerator::Lazy, Array, Hash and Set [Feature #13784] [ruby-core:82285] * Share specs for the various #select#select! methods and reuse them for #filter/#filter!. * Add corresponding filter tests for select tests. * Update NEWS. [Fix GH-1824] From: Alexander Patrick <adp90@case.edu> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62575 b2dd03c8-39d4-4d8f-98ff-823fe69b080e