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

123 Коммитов

Автор SHA1 Сообщение Дата
Kazuki Tsujimoto f360ebb306 [ruby/set] Make Set#pretty_print IRB::ColorPrinter friendly
https://github.com/ruby/set/commit/f467028cdb
2021-09-28 17:37:41 +09:00
BurdetteLamar 1e04571da0 [ruby/set] Improve What's Here links
https://github.com/ruby/set/commit/76b056c3b9
2021-07-29 14:18:52 +09:00
BurdetteLamar 2bd68e32e7 [ruby/set] Improve What's Here links
https://github.com/ruby/set/commit/dd787a3988
2021-07-29 14:18:42 +09:00
Jeremy Evans 52e602edda [ruby/set] Update documentation for intersect?/disjoint?
https://github.com/ruby/set/commit/35b69e9d69
2021-07-29 14:18:25 +09:00
Jeremy Evans cafa7d8975 [ruby/set] Allow the use of any enumerable in intersect?/disjoint?
https://github.com/ruby/set/commit/1a73ab9047
2021-07-29 14:18:18 +09:00
Jeremy Evans 571dafdc7f [ruby/set] Allow Set#intersect? and #disjoint? to accept array argument
Implements [Feature #17838]

https://github.com/ruby/set/commit/d9b389bafa
2021-07-29 14:18:10 +09:00
Burdette Lamar 61e4499545
[ruby/set] Adding section: What's Here
https://github.com/ruby/set/commit/257dc452a7
2021-05-10 16:08:29 +09:00
Burdette Lamar 0a74547942
[ruby/set] Adding section: What's Here
https://github.com/ruby/set/commit/8f4c62768d
2021-05-10 16:08:29 +09:00
Burdette Lamar b8506eb476
[ruby/set] Adding section: What's Here
https://github.com/ruby/set/commit/254d927c8c
2021-05-10 16:08:29 +09:00
Burdette Lamar adc86f7a58
[ruby/set] Adding section: What's Here
https://github.com/ruby/set/commit/ab81354de1
2021-05-10 16:08:29 +09:00
Akinori MUSHA 96b8816793 Import set 1.0.1
- Eliminate warnings
- Convert rdoc to markdown
2020-12-22 21:41:44 +09:00
Akinori MUSHA 3fa4bd8292 Import set 1.0.0
- SortedSet has been removed for dependency and performance reasons.
- Set#join is added as a shorthand for `.to_a.join`.
- Set#<=> is added.

https://github.com/ruby/set/blob/v1.0.0/CHANGELOG.md
2020-12-22 12:20:21 +09:00
Marc-Andre Lafortune 1804c3368c [ruby/set] Add `Set#<=>`
https://github.com/ruby/set/commit/447974a374
2020-12-04 19:24:22 +09:00
Akinori MUSHA a3db08d7b6 [ruby/set] Remove SortedSet implementations
It required RBTree to perform decently and the external dependency was
not suitable for a standard library.  The pure ruby fallback
implementation was originally meant to be an example of how to write a
subclass of Set, and its poor performance was not suitable for use in
production.

I decided it should be distributed as an external library instead of
bundling it with Set.

https://github.com/ruby/set/commit/dfcc8e568b
2020-12-04 19:23:59 +09:00
Akinori MUSHA 46fc8d78a5 [ruby/set] Resurrect support for Ruby 2.x
In Ruby 2.x, initialize_copy does not take a freeze option.

https://github.com/ruby/set/commit/3da6c309df
2020-12-04 19:23:35 +09:00
Jeremy Evans a6cf2f3d22 Make mutating the result of SortedSet#to_a not affect the set
Fixes [Bug #15834]
2020-06-11 14:02:00 -07:00
Jeremy Evans 4f7b435c95 Support obj.clone(freeze: true) for freezing clone
This freezes the clone even if the receiver is not frozen.  It
is only for consistency with freeze: false not freezing the clone
even if the receiver is frozen.

Because Object#clone is now partially implemented in Ruby and
not fully implemented in C, freeze: nil must be supported to
provide the default behavior of only freezing the clone if the
receiver is frozen.

This requires modifying delegate and set, to set freeze: nil
instead of freeze: true as the keyword parameter for
initialize_clone.  Those are the two libraries in stdlib that
override initialize_clone.

Implements [Feature #16175]
2020-03-22 09:30:07 -07:00
Jeremy Evans 04eb7c7e46 Call initialize_clone with freeze: false if clone called with freeze: false
This makes it possible to initialize_clone to correctly not freeze
internal state if the freeze: false keyword is passed to clone.

If clone is called with freeze: true or no keyword, do not pass
a second argument to initialize_clone to keep backwards
compatibility.

This makes it so that external libraries that override
initialize_clone but do not support the freeze keyword will fail
with ArgumentError if passing freeze: false to clone.  I think that
is better than the current behavior, which succeeds but results in
an unfrozen object with frozen internals.

Fix related issues in set and delegate in stdlib.

Fixes [Bug #14266]
2020-01-03 20:13:09 -08:00
Oleg Zubchenko 4ce28b58cb speed up set intersect 2019-12-31 20:52:41 +09:00
Jeremy Evans ffd0820ab3 Deprecate taint/trust and related methods, and make the methods no-ops
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.
2019-11-18 01:00:25 +02:00
Jeremy Evans 258843106f Fix SortedSet subclasses that override initialize
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]
2019-09-06 14:20:22 -07:00
kazu afd68cd871 raise FrozenError instead of RuntimeError
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66875 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-01-20 04:44:25 +00:00
eregon b1a8c64483 Add a new #filter alias for #select
* 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
2018-02-25 13:52:07 +00:00
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