aboutsummaryrefslogtreecommitdiffstats
path: root/lib/set.rb
Commit message (Collapse)AuthorAgeFilesLines
* Fix SortedSet not being sorted the first time when rbtree is usedJeremy Evans2021-07-311-2/+9
| | | | Fixes [Bug #17841]
* Deprecate taint/trust and related methods, and make the methods no-opsJeremy Evans2019-11-181-10/+0
| | | | | | This removes the related tests, and puts the related specs behind version guards. This affects all code in lib, including some libraries that may want to support older versions of Ruby.
* Fix SortedSet subclasses that override initializeJeremy Evans2019-09-061-1/+2
| | | | | | | | | | | | | The first time SortedSet#initialize is called, it overwrites itself, then recalls #initialize, which results in calling the subclass's initialize, not the current initialize. Just inline the default initialize behavior to avoid this issue. No test for this as it can only be triggered the very first time that SortedSet#initialize is called. Fixes [Bug #15830]
* raise FrozenError instead of RuntimeErrorkazu2019-01-201-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66875 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Add a new #filter alias for #selecteregon2018-02-251-0/+3
| | | | | | | | | | | | | | | * 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
* lib/set.rb: [DOC] remove empty commentsstomar2017-11-221-4/+4
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60881 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* set.rb: improve docs for Setstomar2017-11-221-33/+28
| | | | | | | | * lib/set.rb: [DOC] add examples for Set#replace, add examples for creating a set from a hash with duplicates, simplify and fix style of some other examples, fix typos. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60879 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Add examples to Set documentation [ci skip]knu2017-11-171-7/+47
| | | | | | | GitHub PR: https://github.com/ruby/ruby/pull/1752 [Fix GH-1752] Submitted by: @Ana06 <anamma06@gmail.com> git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60824 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* lib/set.rb: improve docs for Set#===stomar2017-10-291-6/+11
| | | | | | * lib/set.rb: [DOC] improve description and examples for Set#===. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60573 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Add `Set#reset`knu2017-10-221-0/+18
| | | | | | | This method resets the internal state of a set after modification to existing elements, reindexing and deduplicating them. [Feature #6589] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60360 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Avoid use of `self.class.new(self)` in Set#collect!knu2017-10-211-1/+3
| | | | | | | | | That prevents infinite recursion when a subclass of Set uses `collect!` in its constructor. This should fix [Bug #12437]. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60317 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Fix comparison methods of Set to check if `@hash` is actually comparableknu2017-10-211-4/+4
| | | | | | | This should fix comparison of rbtree backed SortedSet instances. [Bug #12072] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60312 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Use a mutex to make SortedSet.setup thread-safeknu2017-10-211-90/+92
| | | | | | This should fix [Bug #13735]. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60304 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Remove redundant use of module_evalknu2017-10-211-8/+6
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60303 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Allow a SortedSet to be frozen and still functional [Bug #12091]knu2017-10-211-0/+5
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60298 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Alias Set#=== to #include?knu2017-09-191-0/+17
| | | | | | | | * set.rb (Set#===): Added via [Feature #13801] by davidarnold. Closes #1673. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59966 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Alias Set#to_s to #inspect [ruby-core:81753] [Feature #13676]knu2017-07-141-0/+2
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59332 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Add Set#compare_by_identity and Set#compare_by_identity?knu2016-11-051-2/+20
| | | | | | | * lib/set.rb (Set#compare_by_identity, Set#compare_by_identity?): New methods. [Feature #12210] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56589 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/set.rb: [DOC] add documentation that ↵ktsj2016-05-041-4/+11
| | | | | | | | Set#{delete_if,keep_if,collect!,reject!,select!, classify,divide} without block returns an enumerator. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54904 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/set.rb (Set#{delete_if,keep_if,collect!,reject!,select!,classify,divide},ktsj2016-05-041-9/+9
| | | | | | | | SortedSet#{delete_if,keep_if}): Return sized enumerators. * test/test_set.rb: add test for above. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54903 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/set.rb: Enable frozen_string_literal.knu2015-11-161-1/+3
| | | | | | * lib/set.rb: Move << out of the begin block that ensures pop. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52593 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Explain the reason for calling do_with_enum without a block [ci skip]knu2015-11-161-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52592 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/set.rb (Hash#flatten!, #add?, #delete?, #collect!, #reject!,knu2015-11-161-23/+8
| | | | | | | #select!, #^, #classify): Micro-optimize some methods for performance and readability. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52591 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/set.rb (#>=, #>, #<=, #<): Make use of Hash#>=, #>, #<, andknu2015-11-161-12/+32
| | | | | | #<= when comparing against an instance of the same kind. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52586 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/set.rb: Make Set#each and SortedSet#each generate a sizedknu2015-06-151-2/+2
| | | | | | | | | enumerator. [GH-931] by kachick (Kenichi Kamiya) * test/test_set.rb: Import tests from Set into SortedSet. [GH-931] by kachick (Kenichi Kamiya) git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50908 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * hash.c: Added docs to explain that #include? and #member? do nothsbt2015-02-171-0/+5
| | | | | | | check member equality * lib/set.rb: ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49616 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* set: speed up Set#include?normal2015-02-111-2/+2
| | | | | | | | | | * lib/set.rb (initialize): internal hash defaults to false * lib/set.rb (include?): use Hash#[] for optimized dispatch. Patch by Ismael Abreu <ismaelga@gmail.com> [ruby-core:67664] [Misc #10754] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49568 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/set.rb (Set#replace): Check if an object given is enumerableknu2014-08-061-4/+4
| | | | | | | before clearing self. Reported by yui-knk. [GH-675] https://github.com/ruby/ruby/pull/675 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47085 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Implement Set#clone. [Fixes GH-661]knu2014-08-061-2/+9
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47083 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/set.rb: [DOC] Fix grammatical error by @bouk [fix GH-524]hsbt2014-02-051-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44812 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/set.rb: [DOC] Add examples for Set#intersect? and Set#disjoint?zzak2014-01-281-0/+13
| | | | | | | Patch by xavier nayrac [Bug #9331] [ci skip] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44724 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/set.rb (class SortedSet): Fix source_location for methods defined via ↵tmm12013-11-221-4/+4
| | | | | | eval. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43808 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/set.rb: [DOC] Add a couple of notes on Hash as storage.knu2013-07-311-3/+10
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42265 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/set.rb: [DOC] Fix example result. Hash is now ordered.knu2013-07-311-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42264 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Use the term "sorted" instead "ordered" when mentioning SortSet.knu2013-07-311-1/+1
| | | | | | | * lib/set.rb: [DOC] Use the term "sorted" instead "ordered" when mentioning SortSet. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42263 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Add Set#intersect? and #disjoint?.knu2013-07-301-0/+17
| | | | | | | | * lib/set.rb (Set#intersect?, Set#disjoint?): Add new methods for testing if two sets have any element in common. [ruby-core:45641] [Feature #6588] Based on the code by marcandre. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42253 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Define Set#to_set so that aSet.to_set returns self.knu2013-07-191-0/+10
| | | | | | | * lib/set.rb (Set#to_set): Define Set#to_set so that aSet.to_set returns self. [Fixes GH-359] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42051 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/set.rb (Set#freeze, taint, untaint): Save a "self" byknu2013-06-011-6/+3
| | | | | | utilizing super returning self, and add tests while at it. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41022 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/set.rb (Set#delete_if, Set#keep_if): Avoid blockless call ofknu2013-05-201-3/+3
| | | | | | | proc, which is not portable to JRuby. Replace &method() with faster and simpler literal blocks while at it. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40857 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/set.rb (Set#delete_if, Set#keep_if): Add comments.knu2013-05-191-0/+4
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40827 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/set.rb (Set#delete_if, Set#keep_if): Make Set#delete_if andknu2013-05-181-2/+2
| | | | | | Set#keep_if more space and time efficient by avoiding to_a. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40819 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Move tests embedded in lib/set.rb to test/test_set.rb.knu2012-11-241-644/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37839 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Drop executable bits.knu2012-11-221-0/+0
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37794 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/set.rb (#initialize_copy, #eql): Use instance_variable_getknu2012-09-011-2/+2
| | | | | | instead of instance_eval. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36876 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/set.rb (Set#{each,reject!,select!}, SortedSet#each): Passknu2012-08-311-12/+12
| | | | | | | the original block through instead of creating one that only yields the passed argument. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36869 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/set.rb (Set#{<,>,<=,>=}): Define comparison operators asknu2012-08-301-0/+23
| | | | | | | shorthand for the {proper_}{subset?,superset?} methods (finally). Given a push by Alexander E. Fischer. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36853 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/set.rb (SortedSet.setup): remove old_init after initializeakr2011-11-201-0/+4
| | | | | | | | | method is redefined. The remove before redefinition makes the warning prevention fragile. [ruby-dev:44892] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33796 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/set.rb (SortedSet.setup): don't remove old_init. The removeakr2011-11-201-1/+0
| | | | | | | makes the warning prevention fragile. [ruby-dev:44892] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33795 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * ext/pathname/lib/pathname.rb, ext/tk/lib/multi-tk.rb,ktsj2011-11-051-2/+2
| | | | | | | | | | | | | ext/tk/sample/demos-en/widget, lib/benchmark.rb, lib/irb/cmd/fork.rb, lib/mkmf.rb, lib/net/ftp.rb, lib/net/smtp.rb, lib/open3.rb, lib/pstore.rb, lib/rexml/element.rb, lib/rexml/light/node.rb, lib/rinda/tuplespace.rb, lib/rss/maker/base.rb, lib/rss/maker/entry.rb, lib/scanf.rb, lib/set.rb, lib/shell.rb, lib/shell/command-processor.rb, lib/shell/process-controller.rb, lib/shell/system-command.rb, lib/uri/common.rb: remove unused block arguments to avoid creating Proc objects. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33638 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib: revert r31635-r31638 and untabify with expand(1).nobu2011-05-191-253/+253
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31641 b2dd03c8-39d4-4d8f-98ff-823fe69b080e