Граф коммитов

100 Коммитов

Автор SHA1 Сообщение Дата
stomar 8692d74b09 lib/set.rb: [DOC] remove empty comments
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60881 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-11-22 21:13:51 +00:00
stomar 62191f1cc5 set.rb: improve docs for Set
* 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
2017-11-22 20:58:24 +00:00
knu 8d7d8d0c7f Add examples to Set documentation [ci skip]
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
2017-11-17 09:48:47 +00:00
stomar cd63bec1ed lib/set.rb: improve docs for Set#===
* 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
2017-10-29 20:59:33 +00:00
knu 8c90432af7 Add `Set#reset`
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
2017-10-22 12:25:34 +00:00
knu 0fcac8f1a3 Avoid use of `self.class.new(self)` in Set#collect!
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
2017-10-21 17:03:40 +00:00
knu c1c527c290 Fix comparison methods of Set to check if `@hash` is actually comparable
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
2017-10-21 16:28:52 +00:00
knu 8daa6985dc Use a mutex to make SortedSet.setup thread-safe
This should fix [Bug #13735].

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60304 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-21 15:57:32 +00:00
knu 76e3825376 Remove redundant use of module_eval
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60303 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-21 15:57:26 +00:00
knu 3090169c9b Allow a SortedSet to be frozen and still functional [Bug #12091]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60298 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-10-21 15:38:38 +00:00
knu 2aee703e7a Alias Set#=== to #include?
* 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
2017-09-19 08:45:12 +00:00
knu d893c123f6 Alias Set#to_s to #inspect [ruby-core:81753] [Feature #13676]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59332 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-07-14 08:46:13 +00:00
knu 76977611dd Add Set#compare_by_identity and Set#compare_by_identity?
* 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
2016-11-05 09:23:14 +00:00
ktsj 60287eab74 * lib/set.rb: [DOC] add documentation that 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
2016-05-04 09:07:01 +00:00
ktsj 80ccb8e86f * lib/set.rb (Set#{delete_if,keep_if,collect!,reject!,select!,classify,divide},
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
2016-05-04 09:06:59 +00:00
knu 5cf4310616 * lib/set.rb: Enable frozen_string_literal.
* 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
2015-11-16 07:41:30 +00:00
knu dcfcef1cfd Explain the reason for calling do_with_enum without a block [ci skip]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52592 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-11-16 07:41:18 +00:00
knu 4f018492d3 * lib/set.rb (Hash#flatten!, #add?, #delete?, #collect!, #reject!,
#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
2015-11-16 07:29:37 +00:00
knu d736eded9d * lib/set.rb (#>=, #>, #<=, #<): Make use of Hash#>=, #>, #<, and
#<= 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
2015-11-16 06:43:43 +00:00
knu 9f2e41b7e0 * lib/set.rb: Make Set#each and SortedSet#each generate a sized
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
2015-06-15 05:37:38 +00:00
hsbt f6b9a0feaf * hash.c: Added docs to explain that #include? and #member? do not
check member equality
* lib/set.rb: ditto

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@49616 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2015-02-17 01:47:28 +00:00
normal 709e0ecbda set: speed up Set#include?
* 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
2015-02-11 19:04:16 +00:00
knu 305be780df * lib/set.rb (Set#replace): Check if an object given is enumerable
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
2014-08-06 11:28:21 +00:00
knu 3766aa4cc5 Implement Set#clone. [Fixes GH-661]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47083 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-08-06 10:13:34 +00:00
hsbt b38d16dad9 * lib/set.rb: [DOC] Fix grammatical error by @bouk [fix GH-524]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44812 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2014-02-05 00:33:38 +00:00
zzak fa4af4d4cd * lib/set.rb: [DOC] Add examples for Set#intersect? and Set#disjoint?
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
2014-01-28 06:19:19 +00:00
tmm1 cac4da9858 * lib/set.rb (class SortedSet): Fix source_location for methods defined via eval.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43808 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-11-22 23:50:06 +00:00
knu a5c8e0861f * lib/set.rb: [DOC] Add a couple of notes on Hash as storage.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42265 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-31 05:58:17 +00:00
knu b426f8ebb5 * lib/set.rb: [DOC] Fix example result. Hash is now ordered.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42264 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-07-31 05:58:14 +00:00
knu d950ffe5f5 Use the term "sorted" instead "ordered" when mentioning SortSet.
* 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
2013-07-31 05:58:09 +00:00
knu bd304ed85b Add Set#intersect? and #disjoint?.
* 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
2013-07-30 09:58:13 +00:00
knu ad78cf4ea8 Define Set#to_set so that aSet.to_set returns self.
* 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
2013-07-19 02:22:11 +00:00
knu 6bdfe415df * lib/set.rb (Set#freeze, taint, untaint): Save a "self" by
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
2013-06-01 09:01:16 +00:00
knu dcb4ceeac6 * lib/set.rb (Set#delete_if, Set#keep_if): Avoid blockless call of
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
2013-05-20 13:28:32 +00:00
knu 11c7566aa3 * lib/set.rb (Set#delete_if, Set#keep_if): Add comments.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40827 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-05-19 08:33:27 +00:00
knu 2849ee5d18 * lib/set.rb (Set#delete_if, Set#keep_if): Make Set#delete_if and
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
2013-05-18 17:48:18 +00:00
knu e58d0bd393 Move tests embedded in lib/set.rb to test/test_set.rb.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37839 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-24 18:51:45 +00:00
knu 81632542d8 Drop executable bits.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@37794 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-11-22 05:32:31 +00:00
knu d4fe9e004a * lib/set.rb (#initialize_copy, #eql): Use instance_variable_get
instead of instance_eval.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36876 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2012-09-01 09:51:48 +00:00
knu babb80f4a9 * lib/set.rb (Set#{each,reject!,select!}, SortedSet#each): Pass
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
2012-08-31 08:43:09 +00:00
knu aa7dc0f305 * lib/set.rb (Set#{<,>,<=,>=}): Define comparison operators as
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
2012-08-30 04:01:58 +00:00
akr 901ed0b318 * lib/set.rb (SortedSet.setup): remove old_init after initialize
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
2011-11-20 02:02:14 +00:00
akr 562c42a668 * lib/set.rb (SortedSet.setup): don't remove old_init. The remove
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
2011-11-20 01:21:01 +00:00
ktsj c3749b6a6d * ext/pathname/lib/pathname.rb, ext/tk/lib/multi-tk.rb,
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
2011-11-05 07:37:47 +00:00
nobu d371e3583e * lib: revert r31635-r31638 and untabify with expand(1).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31641 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-05-19 00:07:25 +00:00
drbrain 7bbf2f3085 * lib: Convert tabs to spaces for ruby files per
http://redmine.ruby-lang.org/projects/ruby/wiki/DeveloperHowto#coding-style
	  Patch by Steve Klabnik [Ruby 1.9 - Bug #4730]
	  Patch by Jason Dew [Ruby 1.9 - Feature #4718]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31635 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-05-18 21:19:18 +00:00
nobu 3a47cf3395 * remove trailing spaces.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31573 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-05-15 11:55:52 +00:00
drbrain 6eaa5cb30c * lib/set.rb (class Set): Add nodoc to internal-use methods. Patch by Pete Higgins. [Ruby 1.9 - Bug #4665]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31527 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2011-05-11 23:17:52 +00:00
knu 72ef219804 * lib/set.rb (Set#replace): Apply a bit of optimization.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29434 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-10-10 09:45:36 +00:00
marcandre 1d06ff9761 * lib/set.rb (keep_if, select!): New methods [ruby-core:29749]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28096 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-05-30 13:19:09 +00:00