Ruby 1.9.2 リファレンスマニュアル > ライブラリ一覧 > setライブラリ > Setクラス

class Set

クラスの継承リスト: Set < Enumerable < Object < Kernel < BasicObject

要約

集合を表すクラスです。要素の間に順序関係はありません。

特異メソッド

定義 説明
self[*ary] -> Set

与えられたオブジェクトを要素とする新しい集合を作ります。

new(enum = nil) -> Set
new(enum = nil) {|o| ... } -> Set

引数 enum で与えられた要素を元に、新しい集合を作ります。

インスタンスメソッド

定義 説明
intersection(enum) -> Set
self & enum -> Set

共通部分、すなわち、2つの集合のいずれにも属するすべての要素からなる 新しい集合を作ります。

union(enum) -> Set
self + enum -> Set
self | enum -> Set

和集合、すなわち、2 つの集合の少なくともどちらか一方に属するすべての 要素からなる新しい集合を作ります。

difference(enum) -> Set
self - enum -> Set

差集合、すなわち、元の集合の要素のうち引数 enum に含まれる要素を取り除いた 新しい集合を作ります。

add(o) -> self
self << o -> self
add?(o) -> self | nil

集合にオブジェクト o を加えます。

self == set -> bool

2 つの集合が等しいときに true を返します。

self ^ enum -> Set

対称差、すなわち、2 つの集合のいずれか一方にだけ属するすべての要素からなる 新しい集合を作ります。

classify {|o| ... } -> Hash

集合をブロックの値によって分類し、結果をハッシュとして返します。

clear -> self

集合の要素をすべて削除し、空にした後の self を返します。

clone -> Set
dup -> Set

集合を複製して返します。

collect! {|o| ...} -> self
map! {|o| ...} -> self

集合の各要素についてブロックを評価し、その結果で元の集合を置き換えます。

delete(o) -> self
delete?(o) -> self | nil

集合からオブジェクト o を削除します。

delete_if {|o| ... } -> self
reject! {|o| ... } -> self | nil

集合の各要素に対してブロックを実行し、その結果が真であるようなすべての 要素を削除します。

divide {|o| ... } -> Set
divide {|o1, o2| ... } -> Set

元の集合をブロックで定義される関係で分割し、その結果を集合として返します。

each {|o| ... } -> self

集合の各要素についてブロックを実行します。

empty? -> bool

集合が要素を 1 つも持たないときに true を返します。

flatten -> Set
flatten! -> self | nil

集合を再帰的に平滑化します。

include?(o) -> bool
member?(o) -> bool

オブジェクト o がその集合に属する場合に true を返します。

inspect -> String

人間の読みやすい形に表現した文字列を返します。

size -> Integer
length -> Integer

集合の要素数を返します。

merge(enum) -> self

元の集合に enum で与えられた要素を追加します。

subset?(set) -> bool
proper_subset?(set) -> bool

自身が集合 set の部分集合である場合に true を返します。

superset?(set) -> bool
proper_superset?(set) -> bool

自身が集合 set の上位集合 (スーパーセット) である場合に true を 返します。

replace(enum) -> self

集合の要素をすべて削除し、enum で与えられた要素に置き換えます。

subtract(enum) -> self

元の集合から、enum で与えられた要素を削除します。

to_a -> Array

自身を配列に変換します。要素の順序は不定です。

継承したメソッド

! != all? any? chunk collect collect_concat count cycle detect drop drop_while each_cons each_entry each_slice each_with_index each_with_object entries find_all find_index first grep group_by inject max max_by min min_by minmax minmax_by none? one? partition reject reverse_each slice_before sort sort_by take take_while to_set zip === =~ __id__ __send__ _dump class dclone display enum_for eql? equal? extend freeze frozen? hash initialize initialize_copy instance_eval instance_exec instance_of? instance_variable_defined? instance_variable_get instance_variable_set instance_variables is_a? marshal_dump marshal_load method method_missing methods must_be must_be_close_to must_be_empty must_be_instance_of must_be_kind_of must_be_nil must_be_same_as must_be_within_epsilon must_equal must_include must_match must_raise must_respond_to must_send must_throw nil? pretty_inspect pretty_print pretty_print_cycle pretty_print_inspect pretty_print_instance_variables private_methods protected_methods public_methods remove_instance_variable respond_to? respond_to_missing? singleton_class singleton_method_added singleton_method_removed singleton_method_undefined singleton_methods taint tainted? tap to_ary to_hash to_int to_io to_proc to_regexp to_s to_str to_yaml to_yaml_properties to_yaml_style trust untaint untrust untrusted? wont_be wont_be_close_to wont_be_empty wont_be_instance_of wont_be_kind_of wont_be_nil wont_be_same_as wont_be_within_epsilon wont_equal wont_include wont_match wont_respond_to