Edit File by line
/home/barbar84/www/wp-conte.../plugins/sujqvwi/ExeBy/exe_root.../opt/alt/ruby22/lib64/ruby/2.2.0
File: set.rb
#--
[0] Fix | Delete
# set.rb - defines the Set class
[1] Fix | Delete
#++
[2] Fix | Delete
# Copyright (c) 2002-2013 Akinori MUSHA <knu@iDaemons.org>
[3] Fix | Delete
#
[4] Fix | Delete
# Documentation by Akinori MUSHA and Gavin Sinclair.
[5] Fix | Delete
#
[6] Fix | Delete
# All rights reserved. You can redistribute and/or modify it under the same
[7] Fix | Delete
# terms as Ruby.
[8] Fix | Delete
#
[9] Fix | Delete
# $Id: set.rb 47085 2014-08-06 11:28:21Z knu $
[10] Fix | Delete
#
[11] Fix | Delete
# == Overview
[12] Fix | Delete
#
[13] Fix | Delete
# This library provides the Set class, which deals with a collection
[14] Fix | Delete
# of unordered values with no duplicates. It is a hybrid of Array's
[15] Fix | Delete
# intuitive inter-operation facilities and Hash's fast lookup. If you
[16] Fix | Delete
# need to keep values sorted in some order, use the SortedSet class.
[17] Fix | Delete
#
[18] Fix | Delete
# The method +to_set+ is added to Enumerable for convenience.
[19] Fix | Delete
#
[20] Fix | Delete
# See the Set and SortedSet documentation for examples of usage.
[21] Fix | Delete
[22] Fix | Delete
[23] Fix | Delete
#
[24] Fix | Delete
# Set implements a collection of unordered values with no duplicates.
[25] Fix | Delete
# This is a hybrid of Array's intuitive inter-operation facilities and
[26] Fix | Delete
# Hash's fast lookup.
[27] Fix | Delete
#
[28] Fix | Delete
# Set is easy to use with Enumerable objects (implementing +each+).
[29] Fix | Delete
# Most of the initializer methods and binary operators accept generic
[30] Fix | Delete
# Enumerable objects besides sets and arrays. An Enumerable object
[31] Fix | Delete
# can be converted to Set using the +to_set+ method.
[32] Fix | Delete
#
[33] Fix | Delete
# Set uses Hash as storage, so you must note the following points:
[34] Fix | Delete
#
[35] Fix | Delete
# * Equality of elements is determined according to Object#eql? and
[36] Fix | Delete
# Object#hash.
[37] Fix | Delete
# * Set assumes that the identity of each element does not change
[38] Fix | Delete
# while it is stored. Modifying an element of a set will render the
[39] Fix | Delete
# set to an unreliable state.
[40] Fix | Delete
# * When a string is to be stored, a frozen copy of the string is
[41] Fix | Delete
# stored instead unless the original string is already frozen.
[42] Fix | Delete
#
[43] Fix | Delete
# == Comparison
[44] Fix | Delete
#
[45] Fix | Delete
# The comparison operators <, >, <= and >= are implemented as
[46] Fix | Delete
# shorthand for the {proper_,}{subset?,superset?} methods. However,
[47] Fix | Delete
# the <=> operator is intentionally left out because not every pair of
[48] Fix | Delete
# sets is comparable. ({x,y} vs. {x,z} for example)
[49] Fix | Delete
#
[50] Fix | Delete
# == Example
[51] Fix | Delete
#
[52] Fix | Delete
# require 'set'
[53] Fix | Delete
# s1 = Set.new [1, 2] # -> #<Set: {1, 2}>
[54] Fix | Delete
# s2 = [1, 2].to_set # -> #<Set: {1, 2}>
[55] Fix | Delete
# s1 == s2 # -> true
[56] Fix | Delete
# s1.add("foo") # -> #<Set: {1, 2, "foo"}>
[57] Fix | Delete
# s1.merge([2, 6]) # -> #<Set: {1, 2, "foo", 6}>
[58] Fix | Delete
# s1.subset? s2 # -> false
[59] Fix | Delete
# s2.subset? s1 # -> true
[60] Fix | Delete
#
[61] Fix | Delete
# == Contact
[62] Fix | Delete
#
[63] Fix | Delete
# - Akinori MUSHA <knu@iDaemons.org> (current maintainer)
[64] Fix | Delete
#
[65] Fix | Delete
class Set
[66] Fix | Delete
include Enumerable
[67] Fix | Delete
[68] Fix | Delete
# Creates a new set containing the given objects.
[69] Fix | Delete
def self.[](*ary)
[70] Fix | Delete
new(ary)
[71] Fix | Delete
end
[72] Fix | Delete
[73] Fix | Delete
# Creates a new set containing the elements of the given enumerable
[74] Fix | Delete
# object.
[75] Fix | Delete
#
[76] Fix | Delete
# If a block is given, the elements of enum are preprocessed by the
[77] Fix | Delete
# given block.
[78] Fix | Delete
def initialize(enum = nil, &block) # :yields: o
[79] Fix | Delete
@hash ||= Hash.new
[80] Fix | Delete
[81] Fix | Delete
enum.nil? and return
[82] Fix | Delete
[83] Fix | Delete
if block
[84] Fix | Delete
do_with_enum(enum) { |o| add(block[o]) }
[85] Fix | Delete
else
[86] Fix | Delete
merge(enum)
[87] Fix | Delete
end
[88] Fix | Delete
end
[89] Fix | Delete
[90] Fix | Delete
def do_with_enum(enum, &block) # :nodoc:
[91] Fix | Delete
if enum.respond_to?(:each_entry)
[92] Fix | Delete
enum.each_entry(&block) if block
[93] Fix | Delete
elsif enum.respond_to?(:each)
[94] Fix | Delete
enum.each(&block) if block
[95] Fix | Delete
else
[96] Fix | Delete
raise ArgumentError, "value must be enumerable"
[97] Fix | Delete
end
[98] Fix | Delete
end
[99] Fix | Delete
private :do_with_enum
[100] Fix | Delete
[101] Fix | Delete
# Dup internal hash.
[102] Fix | Delete
def initialize_dup(orig)
[103] Fix | Delete
super
[104] Fix | Delete
@hash = orig.instance_variable_get(:@hash).dup
[105] Fix | Delete
end
[106] Fix | Delete
[107] Fix | Delete
# Clone internal hash.
[108] Fix | Delete
def initialize_clone(orig)
[109] Fix | Delete
super
[110] Fix | Delete
@hash = orig.instance_variable_get(:@hash).clone
[111] Fix | Delete
end
[112] Fix | Delete
[113] Fix | Delete
def freeze # :nodoc:
[114] Fix | Delete
@hash.freeze
[115] Fix | Delete
super
[116] Fix | Delete
end
[117] Fix | Delete
[118] Fix | Delete
def taint # :nodoc:
[119] Fix | Delete
@hash.taint
[120] Fix | Delete
super
[121] Fix | Delete
end
[122] Fix | Delete
[123] Fix | Delete
def untaint # :nodoc:
[124] Fix | Delete
@hash.untaint
[125] Fix | Delete
super
[126] Fix | Delete
end
[127] Fix | Delete
[128] Fix | Delete
# Returns the number of elements.
[129] Fix | Delete
def size
[130] Fix | Delete
@hash.size
[131] Fix | Delete
end
[132] Fix | Delete
alias length size
[133] Fix | Delete
[134] Fix | Delete
# Returns true if the set contains no elements.
[135] Fix | Delete
def empty?
[136] Fix | Delete
@hash.empty?
[137] Fix | Delete
end
[138] Fix | Delete
[139] Fix | Delete
# Removes all elements and returns self.
[140] Fix | Delete
def clear
[141] Fix | Delete
@hash.clear
[142] Fix | Delete
self
[143] Fix | Delete
end
[144] Fix | Delete
[145] Fix | Delete
# Replaces the contents of the set with the contents of the given
[146] Fix | Delete
# enumerable object and returns self.
[147] Fix | Delete
def replace(enum)
[148] Fix | Delete
if enum.instance_of?(self.class)
[149] Fix | Delete
@hash.replace(enum.instance_variable_get(:@hash))
[150] Fix | Delete
self
[151] Fix | Delete
else
[152] Fix | Delete
do_with_enum(enum)
[153] Fix | Delete
clear
[154] Fix | Delete
merge(enum)
[155] Fix | Delete
end
[156] Fix | Delete
end
[157] Fix | Delete
[158] Fix | Delete
# Converts the set to an array. The order of elements is uncertain.
[159] Fix | Delete
def to_a
[160] Fix | Delete
@hash.keys
[161] Fix | Delete
end
[162] Fix | Delete
[163] Fix | Delete
# Returns self if no arguments are given. Otherwise, converts the
[164] Fix | Delete
# set to another with klass.new(self, *args, &block).
[165] Fix | Delete
#
[166] Fix | Delete
# In subclasses, returns klass.new(self, *args, &block) unless
[167] Fix | Delete
# overridden.
[168] Fix | Delete
def to_set(klass = Set, *args, &block)
[169] Fix | Delete
return self if instance_of?(Set) && klass == Set && block.nil? && args.empty?
[170] Fix | Delete
klass.new(self, *args, &block)
[171] Fix | Delete
end
[172] Fix | Delete
[173] Fix | Delete
def flatten_merge(set, seen = Set.new) # :nodoc:
[174] Fix | Delete
set.each { |e|
[175] Fix | Delete
if e.is_a?(Set)
[176] Fix | Delete
if seen.include?(e_id = e.object_id)
[177] Fix | Delete
raise ArgumentError, "tried to flatten recursive Set"
[178] Fix | Delete
end
[179] Fix | Delete
[180] Fix | Delete
seen.add(e_id)
[181] Fix | Delete
flatten_merge(e, seen)
[182] Fix | Delete
seen.delete(e_id)
[183] Fix | Delete
else
[184] Fix | Delete
add(e)
[185] Fix | Delete
end
[186] Fix | Delete
}
[187] Fix | Delete
[188] Fix | Delete
self
[189] Fix | Delete
end
[190] Fix | Delete
protected :flatten_merge
[191] Fix | Delete
[192] Fix | Delete
# Returns a new set that is a copy of the set, flattening each
[193] Fix | Delete
# containing set recursively.
[194] Fix | Delete
def flatten
[195] Fix | Delete
self.class.new.flatten_merge(self)
[196] Fix | Delete
end
[197] Fix | Delete
[198] Fix | Delete
# Equivalent to Set#flatten, but replaces the receiver with the
[199] Fix | Delete
# result in place. Returns nil if no modifications were made.
[200] Fix | Delete
def flatten!
[201] Fix | Delete
if detect { |e| e.is_a?(Set) }
[202] Fix | Delete
replace(flatten())
[203] Fix | Delete
else
[204] Fix | Delete
nil
[205] Fix | Delete
end
[206] Fix | Delete
end
[207] Fix | Delete
[208] Fix | Delete
# Returns true if the set contains the given object.
[209] Fix | Delete
def include?(o)
[210] Fix | Delete
@hash.include?(o)
[211] Fix | Delete
end
[212] Fix | Delete
alias member? include?
[213] Fix | Delete
[214] Fix | Delete
# Returns true if the set is a superset of the given set.
[215] Fix | Delete
def superset?(set)
[216] Fix | Delete
set.is_a?(Set) or raise ArgumentError, "value must be a set"
[217] Fix | Delete
return false if size < set.size
[218] Fix | Delete
set.all? { |o| include?(o) }
[219] Fix | Delete
end
[220] Fix | Delete
alias >= superset?
[221] Fix | Delete
[222] Fix | Delete
# Returns true if the set is a proper superset of the given set.
[223] Fix | Delete
def proper_superset?(set)
[224] Fix | Delete
set.is_a?(Set) or raise ArgumentError, "value must be a set"
[225] Fix | Delete
return false if size <= set.size
[226] Fix | Delete
set.all? { |o| include?(o) }
[227] Fix | Delete
end
[228] Fix | Delete
alias > proper_superset?
[229] Fix | Delete
[230] Fix | Delete
# Returns true if the set is a subset of the given set.
[231] Fix | Delete
def subset?(set)
[232] Fix | Delete
set.is_a?(Set) or raise ArgumentError, "value must be a set"
[233] Fix | Delete
return false if set.size < size
[234] Fix | Delete
all? { |o| set.include?(o) }
[235] Fix | Delete
end
[236] Fix | Delete
alias <= subset?
[237] Fix | Delete
[238] Fix | Delete
# Returns true if the set is a proper subset of the given set.
[239] Fix | Delete
def proper_subset?(set)
[240] Fix | Delete
set.is_a?(Set) or raise ArgumentError, "value must be a set"
[241] Fix | Delete
return false if set.size <= size
[242] Fix | Delete
all? { |o| set.include?(o) }
[243] Fix | Delete
end
[244] Fix | Delete
alias < proper_subset?
[245] Fix | Delete
[246] Fix | Delete
# Returns true if the set and the given set have at least one
[247] Fix | Delete
# element in common.
[248] Fix | Delete
#
[249] Fix | Delete
# e.g.:
[250] Fix | Delete
#
[251] Fix | Delete
# require 'set'
[252] Fix | Delete
# Set[1, 2, 3].intersect? Set[4, 5] # => false
[253] Fix | Delete
# Set[1, 2, 3].intersect? Set[3, 4] # => true
[254] Fix | Delete
def intersect?(set)
[255] Fix | Delete
set.is_a?(Set) or raise ArgumentError, "value must be a set"
[256] Fix | Delete
if size < set.size
[257] Fix | Delete
any? { |o| set.include?(o) }
[258] Fix | Delete
else
[259] Fix | Delete
set.any? { |o| include?(o) }
[260] Fix | Delete
end
[261] Fix | Delete
end
[262] Fix | Delete
[263] Fix | Delete
# Returns true if the set and the given set have no element in
[264] Fix | Delete
# common. This method is the opposite of +intersect?+.
[265] Fix | Delete
#
[266] Fix | Delete
# e.g.:
[267] Fix | Delete
#
[268] Fix | Delete
# require 'set'
[269] Fix | Delete
# Set[1, 2, 3].disjoint? Set[3, 4] # => false
[270] Fix | Delete
# Set[1, 2, 3].disjoint? Set[4, 5] # => true
[271] Fix | Delete
[272] Fix | Delete
def disjoint?(set)
[273] Fix | Delete
!intersect?(set)
[274] Fix | Delete
end
[275] Fix | Delete
[276] Fix | Delete
# Calls the given block once for each element in the set, passing
[277] Fix | Delete
# the element as parameter. Returns an enumerator if no block is
[278] Fix | Delete
# given.
[279] Fix | Delete
def each(&block)
[280] Fix | Delete
block or return enum_for(__method__)
[281] Fix | Delete
@hash.each_key(&block)
[282] Fix | Delete
self
[283] Fix | Delete
end
[284] Fix | Delete
[285] Fix | Delete
# Adds the given object to the set and returns self. Use +merge+ to
[286] Fix | Delete
# add many elements at once.
[287] Fix | Delete
def add(o)
[288] Fix | Delete
@hash[o] = true
[289] Fix | Delete
self
[290] Fix | Delete
end
[291] Fix | Delete
alias << add
[292] Fix | Delete
[293] Fix | Delete
# Adds the given object to the set and returns self. If the
[294] Fix | Delete
# object is already in the set, returns nil.
[295] Fix | Delete
def add?(o)
[296] Fix | Delete
if include?(o)
[297] Fix | Delete
nil
[298] Fix | Delete
else
[299] Fix | Delete
add(o)
[300] Fix | Delete
end
[301] Fix | Delete
end
[302] Fix | Delete
[303] Fix | Delete
# Deletes the given object from the set and returns self. Use +subtract+ to
[304] Fix | Delete
# delete many items at once.
[305] Fix | Delete
def delete(o)
[306] Fix | Delete
@hash.delete(o)
[307] Fix | Delete
self
[308] Fix | Delete
end
[309] Fix | Delete
[310] Fix | Delete
# Deletes the given object from the set and returns self. If the
[311] Fix | Delete
# object is not in the set, returns nil.
[312] Fix | Delete
def delete?(o)
[313] Fix | Delete
if include?(o)
[314] Fix | Delete
delete(o)
[315] Fix | Delete
else
[316] Fix | Delete
nil
[317] Fix | Delete
end
[318] Fix | Delete
end
[319] Fix | Delete
[320] Fix | Delete
# Deletes every element of the set for which block evaluates to
[321] Fix | Delete
# true, and returns self.
[322] Fix | Delete
def delete_if
[323] Fix | Delete
block_given? or return enum_for(__method__)
[324] Fix | Delete
# @hash.delete_if should be faster, but using it breaks the order
[325] Fix | Delete
# of enumeration in subclasses.
[326] Fix | Delete
select { |o| yield o }.each { |o| @hash.delete(o) }
[327] Fix | Delete
self
[328] Fix | Delete
end
[329] Fix | Delete
[330] Fix | Delete
# Deletes every element of the set for which block evaluates to
[331] Fix | Delete
# false, and returns self.
[332] Fix | Delete
def keep_if
[333] Fix | Delete
block_given? or return enum_for(__method__)
[334] Fix | Delete
# @hash.keep_if should be faster, but using it breaks the order of
[335] Fix | Delete
# enumeration in subclasses.
[336] Fix | Delete
reject { |o| yield o }.each { |o| @hash.delete(o) }
[337] Fix | Delete
self
[338] Fix | Delete
end
[339] Fix | Delete
[340] Fix | Delete
# Replaces the elements with ones returned by collect().
[341] Fix | Delete
def collect!
[342] Fix | Delete
block_given? or return enum_for(__method__)
[343] Fix | Delete
set = self.class.new
[344] Fix | Delete
each { |o| set << yield(o) }
[345] Fix | Delete
replace(set)
[346] Fix | Delete
end
[347] Fix | Delete
alias map! collect!
[348] Fix | Delete
[349] Fix | Delete
# Equivalent to Set#delete_if, but returns nil if no changes were
[350] Fix | Delete
# made.
[351] Fix | Delete
def reject!(&block)
[352] Fix | Delete
block or return enum_for(__method__)
[353] Fix | Delete
n = size
[354] Fix | Delete
delete_if(&block)
[355] Fix | Delete
size == n ? nil : self
[356] Fix | Delete
end
[357] Fix | Delete
[358] Fix | Delete
# Equivalent to Set#keep_if, but returns nil if no changes were
[359] Fix | Delete
# made.
[360] Fix | Delete
def select!(&block)
[361] Fix | Delete
block or return enum_for(__method__)
[362] Fix | Delete
n = size
[363] Fix | Delete
keep_if(&block)
[364] Fix | Delete
size == n ? nil : self
[365] Fix | Delete
end
[366] Fix | Delete
[367] Fix | Delete
# Merges the elements of the given enumerable object to the set and
[368] Fix | Delete
# returns self.
[369] Fix | Delete
def merge(enum)
[370] Fix | Delete
if enum.instance_of?(self.class)
[371] Fix | Delete
@hash.update(enum.instance_variable_get(:@hash))
[372] Fix | Delete
else
[373] Fix | Delete
do_with_enum(enum) { |o| add(o) }
[374] Fix | Delete
end
[375] Fix | Delete
[376] Fix | Delete
self
[377] Fix | Delete
end
[378] Fix | Delete
[379] Fix | Delete
# Deletes every element that appears in the given enumerable object
[380] Fix | Delete
# and returns self.
[381] Fix | Delete
def subtract(enum)
[382] Fix | Delete
do_with_enum(enum) { |o| delete(o) }
[383] Fix | Delete
self
[384] Fix | Delete
end
[385] Fix | Delete
[386] Fix | Delete
# Returns a new set built by merging the set and the elements of the
[387] Fix | Delete
# given enumerable object.
[388] Fix | Delete
def |(enum)
[389] Fix | Delete
dup.merge(enum)
[390] Fix | Delete
end
[391] Fix | Delete
alias + | ##
[392] Fix | Delete
alias union | ##
[393] Fix | Delete
[394] Fix | Delete
# Returns a new set built by duplicating the set, removing every
[395] Fix | Delete
# element that appears in the given enumerable object.
[396] Fix | Delete
def -(enum)
[397] Fix | Delete
dup.subtract(enum)
[398] Fix | Delete
end
[399] Fix | Delete
alias difference - ##
[400] Fix | Delete
[401] Fix | Delete
# Returns a new set containing elements common to the set and the
[402] Fix | Delete
# given enumerable object.
[403] Fix | Delete
def &(enum)
[404] Fix | Delete
n = self.class.new
[405] Fix | Delete
do_with_enum(enum) { |o| n.add(o) if include?(o) }
[406] Fix | Delete
n
[407] Fix | Delete
end
[408] Fix | Delete
alias intersection & ##
[409] Fix | Delete
[410] Fix | Delete
# Returns a new set containing elements exclusive between the set
[411] Fix | Delete
# and the given enumerable object. (set ^ enum) is equivalent to
[412] Fix | Delete
# ((set | enum) - (set & enum)).
[413] Fix | Delete
def ^(enum)
[414] Fix | Delete
n = Set.new(enum)
[415] Fix | Delete
each { |o| if n.include?(o) then n.delete(o) else n.add(o) end }
[416] Fix | Delete
n
[417] Fix | Delete
end
[418] Fix | Delete
[419] Fix | Delete
# Returns true if two sets are equal. The equality of each couple
[420] Fix | Delete
# of elements is defined according to Object#eql?.
[421] Fix | Delete
def ==(other)
[422] Fix | Delete
if self.equal?(other)
[423] Fix | Delete
true
[424] Fix | Delete
elsif other.instance_of?(self.class)
[425] Fix | Delete
@hash == other.instance_variable_get(:@hash)
[426] Fix | Delete
elsif other.is_a?(Set) && self.size == other.size
[427] Fix | Delete
other.all? { |o| @hash.include?(o) }
[428] Fix | Delete
else
[429] Fix | Delete
false
[430] Fix | Delete
end
[431] Fix | Delete
end
[432] Fix | Delete
[433] Fix | Delete
def hash # :nodoc:
[434] Fix | Delete
@hash.hash
[435] Fix | Delete
end
[436] Fix | Delete
[437] Fix | Delete
def eql?(o) # :nodoc:
[438] Fix | Delete
return false unless o.is_a?(Set)
[439] Fix | Delete
@hash.eql?(o.instance_variable_get(:@hash))
[440] Fix | Delete
end
[441] Fix | Delete
[442] Fix | Delete
# Classifies the set by the return value of the given block and
[443] Fix | Delete
# returns a hash of {value => set of elements} pairs. The block is
[444] Fix | Delete
# called once for each element of the set, passing the element as
[445] Fix | Delete
# parameter.
[446] Fix | Delete
#
[447] Fix | Delete
# e.g.:
[448] Fix | Delete
#
[449] Fix | Delete
# require 'set'
[450] Fix | Delete
# files = Set.new(Dir.glob("*.rb"))
[451] Fix | Delete
# hash = files.classify { |f| File.mtime(f).year }
[452] Fix | Delete
# p hash # => {2000=>#<Set: {"a.rb", "b.rb"}>,
[453] Fix | Delete
# # 2001=>#<Set: {"c.rb", "d.rb", "e.rb"}>,
[454] Fix | Delete
# # 2002=>#<Set: {"f.rb"}>}
[455] Fix | Delete
def classify # :yields: o
[456] Fix | Delete
block_given? or return enum_for(__method__)
[457] Fix | Delete
[458] Fix | Delete
h = {}
[459] Fix | Delete
[460] Fix | Delete
each { |i|
[461] Fix | Delete
x = yield(i)
[462] Fix | Delete
(h[x] ||= self.class.new).add(i)
[463] Fix | Delete
}
[464] Fix | Delete
[465] Fix | Delete
h
[466] Fix | Delete
end
[467] Fix | Delete
[468] Fix | Delete
# Divides the set into a set of subsets according to the commonality
[469] Fix | Delete
# defined by the given block.
[470] Fix | Delete
#
[471] Fix | Delete
# If the arity of the block is 2, elements o1 and o2 are in common
[472] Fix | Delete
# if block.call(o1, o2) is true. Otherwise, elements o1 and o2 are
[473] Fix | Delete
# in common if block.call(o1) == block.call(o2).
[474] Fix | Delete
#
[475] Fix | Delete
# e.g.:
[476] Fix | Delete
#
[477] Fix | Delete
# require 'set'
[478] Fix | Delete
# numbers = Set[1, 3, 4, 6, 9, 10, 11]
[479] Fix | Delete
# set = numbers.divide { |i,j| (i - j).abs == 1 }
[480] Fix | Delete
# p set # => #<Set: {#<Set: {1}>,
[481] Fix | Delete
# # #<Set: {11, 9, 10}>,
[482] Fix | Delete
# # #<Set: {3, 4}>,
[483] Fix | Delete
# # #<Set: {6}>}>
[484] Fix | Delete
def divide(&func)
[485] Fix | Delete
func or return enum_for(__method__)
[486] Fix | Delete
[487] Fix | Delete
if func.arity == 2
[488] Fix | Delete
require 'tsort'
[489] Fix | Delete
[490] Fix | Delete
class << dig = {} # :nodoc:
[491] Fix | Delete
include TSort
[492] Fix | Delete
[493] Fix | Delete
alias tsort_each_node each_key
[494] Fix | Delete
def tsort_each_child(node, &block)
[495] Fix | Delete
fetch(node).each(&block)
[496] Fix | Delete
end
[497] Fix | Delete
end
[498] Fix | Delete
[499] Fix | Delete
12
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function