| Class | Multimap |
| In: |
multiset/libmultimap.rb
|
| Parent: | Object |
Rubyによる多重連想配列(マルチマップ)の実装です。 通常の連想配列(Rubyでは"Hash"クラス)と異なり、多重連想配列は 1つのキーに対して複数の要素が存在し得ます。
メソッド名は基本的にHashクラスに合わせてあります。またHashクラスが持つ メソッドの大部分を実装していますが、いくつか未実装なものもあります。
Ruby implementation of multimap. Unlike ordinary map, also known as associative array (see Ruby documentation for "Hash" class), multimap can contain two or more items for a key.
Most methods’ names are same as those of Hash class, and all other than a few methods in Hash class is implemented on Multimap class.
新しい多重連想配列を生成します。Hash#newと異なり、デフォルト値は 設定できません。
Generates a new multimap. Different from Hash#new , you can not specify default value.
ブロックにselfのキーと値の組(値は1つ)を順次与え、 結果が真であった組をすべて削除します。 selfを返します。
Gives all pairs of a key and single value in self to given block, and deletes that element if the block returns true. Returns self.
selfのすべての値について繰り返します。 selfを返します。
Iterates for each value in self. Returns self.
キーkeyに対応する値(複数存在しうる)を、 Multisetとして返します。Hash#fetchの場合と異なり、キーに対応する 値が存在しない場合の扱いを指定することはできません。 (そのような場合、空のMultisetが返ります。)
Returns values associated with key with format of Multiset. Different from Hash#fetch, you can not specify a value or a process when key has not associated with any value. If key has not associated with any value, Multimap#fetch returns empty Multiset.
selfのキーと値を入れ替えたMultimapを返します。 例えばキー:aに対応する値が2つの:xと1つの:yであれば、変換結果は キー:xに:aが2つ、キー:yに:aが1つ対応するMultimapです。
Returns a Multimap whose keys are values in self, and values are keys in self. For example, If self has a key :a associated with two :x and one :y, returned multimap has two keys :x and :y, and their values are two :a and one :a respectively.
キーkeyに対応する値(複数存在しうる)を value_listで置き換えます。この際、 value_listはMultiset.parseを用いてMultisetに変換されます。
value_listを返します。
Sets values associated with key to value_list. value_list is converted to a Multiset by Multiset.parse .
Returns value_list.
selfをHashに変換して返します。 生成されるハッシュの構造については、Hash#to_multimapをご覧下さい。 その際、返されるハッシュにおいて値はすべてMultimap型となります。
Converts self to a Hash. See Hash#to_multimap about format of generated hash. All values in the returned hash are multimaps.