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

80 Коммитов

Автор SHA1 Сообщение Дата
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
knu e1d9adcc84 Fri Feb 12 02:27:39 2010 Akinori MUSHA <knu@iDaemons.org>
* lib/set.rb (Set#initialize, Set#replace, Set#merge)
	  (Set#subtract, Set#&): Fix duck type tests. [ruby-core:28078]

	* lib/set.rb (Set#initialize, Set#replace, Set#merge)
	  (Set#subtract, Set#&): Try #each if #each_entry fails.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26648 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-02-11 17:38:05 +00:00
matz 970e90dd15 * enum.c (enum_each_entry): new method #each_entry to pack values
from yield into an array.

* lib/set.rb (Set#merge): use Enumerable#each_entry to implement
  Set compatible to 1.8 behavior.  [ruby-core:27985]

* lib/set.rb: replace is_a?(Enumerable) with respond_to?(:each)
  for duck typing.

* lib/set.rb (SortedSet#add): typo fixed.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26540 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2010-02-02 08:54:52 +00:00
marcandre a88cc058f0 * lib/set.rb: Add checks that passed argument is Enumerable. [ruby-core:23844]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26120 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-12-19 00:29:54 +00:00
marcandre 8ef3af646f * lib/set.rb (==): Optimization; patch by Arthur Schreiber [ruby-core:17203]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24910 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-09-13 19:09:36 +00:00
knu 77b04fb6d5 * lib/set.rb (SortedSet#add): Do not require each newly added
element to be Comparable but to respond to <=>. [ruby-dev:38371]



git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23363 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-05-07 17:32:48 +00:00
knu 92c89f12fb * lib/set.rb (SortedSet): Fix document. [Bug #1429]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23326 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-05-02 13:54:09 +00:00
knu f7b562ef01 * lib/set.rb (Set#merge): Only directly use the passed objects
@hash instance variable when self and the passed object are
  instances of the same class. [Bug #118]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23321 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-05-01 07:52:09 +00:00
knu 8dded0725b * lib/set.rb (SortedSet#add): Do not let an uncomparable object
in. [Bug #118]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23320 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-05-01 07:46:23 +00:00
nobu 287a34ae0d * {ext,lib,test}/**/*.rb: removed trailing spaces.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22784 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2009-03-06 03:56:38 +00:00
knu d4b7cc796c * golf_prelude.rb, lib/set.rb (TC_Set#test_each),
test/readline/test_readline_history.rb (Readline#test_each__enumerator),
  test/ruby/test_array.rb (TestArray#test_collect),
  test/ruby/test_enumerator.rb (TestEnumerator#test_initialize):
  Enumerable::Enumerator is now called Enumerator.

* lib/rinda/tuplespace.rb (Rinda::TupleBag#initialize): Use
  enum_for instead of hardcoding Enumerable::Enumerator.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18571 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-08-13 08:03:30 +00:00
knu 250dd07021 * lib/set.rb (Set#delete_if): Call to_a.
(SortedSet#delete_if, TC_SortedSet#test_sortedset): Use super to
  yield elements in sorted order; [ruby-core:17144] by Arthur
  Schreiber.
  (SortedSet#each, SortedSet#each, TC_Set#test_each)
  (TC_SortedSet#test_sortedset): Return self; [ruby-dev:35002] by
  Arthur Schreiber.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@17045 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-06-09 08:58:30 +00:00
knu 3bd8032918 * lib/set.rb (Set#classify): Back out the `group_by' alias.
Better think twice.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16777 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-06-03 06:13:22 +00:00
knu 54fbbb4884 Properly back out.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16773 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-06-03 06:04:54 +00:00
knu 489bf84b9f * lib/set.rb (Set#collect, Set#select): Back out. I thought it
was consistent but turned out to be wrong.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16772 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-06-03 06:01:29 +00:00
knu ea40df71fc * lib/set.rb (Set#collect, Set#select): Override Enumerable
methods and make them return a set. [ruby-core:17055]
  (Set#delete_if, Set#collect!, Set#reject!, Set#classify)
  (Set#divide, Set#delete_if): Return an enumerator if no block is
  given.
  (Set#classify): Define an alias `group_by' to override that of
  Enumerable.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16771 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-06-03 04:42:32 +00:00
knu e7f65f6ba7 * lib/set.rb (Set#each, SortedSet#each, TC_Set#test_each): Return
an enumerator if no block is given.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16169 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-04-23 02:58:46 +00:00
knu 47d42038b3 * lib/ipaddr.rb: Say that I am the current maintainer.
* lib/set.rb: Ditto.

* lib/shellwords.rb: Ditto.

* ext/syslog/syslog.txt: Ditto.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15821 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2008-03-21 12:15:06 +00:00
knu 4503c8daeb * lib/set.rb: Revise rdoc.
* lib/set.rb (Set#freeze, Set#taint, Set#untaint): Implement
  Set#freeze, Set#taint, and Set#untaint; requested by: Dan
  Hutchings <dan AT moltoagitato.com> in [ruby-bugs:PR#9359].


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12104 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-03-20 02:09:10 +00:00
knu ebba0b4340 * lib/set.rb (Set#^, Set#&): Correct documentation. Those methods
return sets, not arrays; noted by Oliver Frank Wittich <nietz AT
  mangabrain.de>.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11978 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-03-03 16:04:57 +00:00
knu 12f9e1b64d * lib/set.rb (Set#^): Fix XOR operation against a container that
holds duplicate values. [issue: #6444]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11263 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-11-02 05:45:12 +00:00