ハッシュ テーブルのパラメータ化クラス。
説明
注意事項
注意事項
注意事項
| self の efficient-size を取得または設定します。 |
| コレクションの要素数を返します。 |
| すべての要素を削除します。 |
| ハッシュ テーブルのクローンを返します。 |
| (フィルタ操作内で要素を使って) クローンの要素が選別された、コレクションのクローンを返します。 |
| (フィルタ操作内でキーを使って) 要素が選別された、コレクションのクローンを返します。 |
| key でインデックス付けされた要素と、示された要素が見つかったかどうかを示すブール値を返します。 |
| 特定のキーと、示された要素が見つかったかどうかを示すブール値を返します。 |
| ハッシュ テーブルを内部的に表す構造を大きくします。 |
| キーが存在するかどうかを調べます。 |
| コレクションの各キーを含む |
| クラス インスタンスが書き込まれるときに、シリアル化コードで呼び出されます。 |
| self を再ハッシュします。 |
| 要素を削除します。 |
| 要素の値を設定します。 |
| self の要素を生成する |
説明
コレクションの要素数を返します。
戻り値
例
| 例 | |
{value
|| Declare and initialize a hash table with
|| String keys and int elements.
let price:{HashTable-of String, int} =
{new {HashTable-of String, int},
"apple", 56,
"banana", 87,
"cherry", 34
}
|| Display a message indicating the size of
|| the hash table.
{text There are {value price.size} elements in
the hash table.}
}
|
注意事項
すべての要素を削除します。
例
| 例 | |
{value
|| Declare and initialize a hash table with
|| int keys and String elements.
let my-table:{HashTable-of int, String} =
{new {HashTable-of int, String},
162094, "tom",
439853, "dick",
098627, "harry"
}
|| Clear the hash table.
{my-table.clear}
|| Check if the hash table is empty.
{text The assertion that the hash table is empty is...
{value my-table.empty?}}
}
|
ハッシュ テーブルのクローンを返します。
戻り値
説明
例
| 例 | |
![]() | |
|| Declare and initialize a hash table with
|| String keys and int elements.
{let table-1:{HashTable-of int, String} =
{new {HashTable-of int, String},
162094, "tom",
439853, "dick",
098627, "harry"
}
}
|| Declare table-2 (a target hash table) and initialize it with
|| a copy of the contents of table-1.
{let table-2:{HashTable-of int, String} = {table-1.clone}}
|| Use a VBox to display the contents of table-2.
|| For each key in table-2 add an HBox to the VBox.
|| The HBox contains the relevant key and element.
|| Then display the VBox.
{let message:VBox = {VBox}}
{for key i:int in table-2 do
{message.add {HBox i, " ", {table-2.get i}}}
}
{value message}
|
注意事項
(フィルタ操作内で要素を使って) クローンの要素が選別された、コレクションのクローンを返します。
戻り値
説明
例
| 例 | |
{value
|| Declare and initialize a hash table with
|| int keys and String elements.
let my-table-1:{HashTable-of int, String} =
{new {HashTable-of int, String},
162094, "tom",
439853, "dick",
098627, "harry"
}
|| Create a clone my-table-2 that contains the elements
|| of my-table-1 with strings that begin with the letter
|| 'd' filtered out.
let my-table-2:{HashTable-of int, String} =
{my-table-1.filter-clone
{proc {str:String}:bool
{return str[0] != 'd'}
}
}
|| Use a VBox to display the contents of my-table-2.
|| Iterate over the contents of my-table-2, adding
|| them to the VBox. Then display the VBox.
let message:VBox = {VBox}
{for each-element:String in my-table-2 do
{message.add each-element}
}
message
|| Note that the order of the elements in a hash
|| table is arbitrary.
}
|
注意事項
(フィルタ操作内でキーを使って) 要素が選別された、コレクションのクローンを返します。
戻り値
説明
例
| 例 | |
{value
|| Declare and initialize a hash table with
|| String keys and int elements.
let quantity:{HashTable-of String, int} =
{new {HashTable-of String, int},
"apple", 3,
"banana", 0,
"cherry", 8
}
|| Create a clone that contains the elements of the
|| original with keys that begin with the letter
|| 'a' filtered out.
let new-quantity:{HashTable-of String, int} =
{quantity.filter-keys-clone
{proc {str:String}:bool
{return str[0] != 'a'}
}
}
|| Use a VBox to display the contents of quantity.
|| For each key in quantity, add the key to the VBox.
|| Then display the VBox.
let message:VBox = {VBox}
{for key each-element:String in new-quantity do
{message.add each-element}
}
message
|| Note that the order of the elements in a hash
|| table is arbitrary.
}
|
注意事項
key でインデックス付けされた要素と、示された要素が見つかったかどうかを示すブール値を返します。
戻り値
特定のキーと、示された要素が見つかったかどうかを示すブール値を返します。
戻り値
説明
例
| 例 | |
|| Declare and initialize a hash table with
|| String keys and int elements.
{let price:{HashTable-of String, int} =
{new {HashTable-of String, int},
"apple", 56,
"banana", 87,
"cherry", 34
}
}
|| Use the get-key-if-exists method to check for the
|| presence of keys.
The hash table contains prices for...
{price.get-key-if-exists "apple"}
{price.get-key-if-exists "banana"}
{price.get-key-if-exists "pear"}
{price.get-key-if-exists "cherry"}
{price.get-key-if-exists "orange"}
|
注意事項
ハッシュ テーブルを内部的に表す構造を大きくします。
説明
キーが存在するかどうかを調べます。
戻り値
例
| 例 | |
{value
|| Declare and initialize a hash table with
|| String keys and int elements.
let price:{HashTable-of String, int} =
{new {HashTable-of String, int},
"apple", 56,
"banana", 87,
"cherry", 34
}
|| Check if there is an element with the
|| key "banana" in the collection "price".
{if {price.key-exists? "banana"} then
{text It is there!}
else
{text It is not there.}
}
}
|
コレクションの各キーを含む
戻り値
説明
例
| 例 | |
{value
|| Declare and initialize a hash table with
|| int keys and String elements.
let my-table:{HashTable-of int, String} =
{new {HashTable-of int, String},
162094, "tom",
439853, "dick",
098627, "harry"
}
|| Create an Iterator-of from the set.
let my-iterator:{Iterator-of int} =
{my-table.keys-to-Iterator}
|| Use a VBox to display the contents of my-iterator.
|| Iterate over the contents of my-iterator, adding
|| them to the VBox. Then display the VBox.
let message:VBox = {VBox}
{for each-element:int in my-iterator do
{message.add each-element}
}
message
|| Note that the order of the elements in a hash
|| table is arbitrary.
}
|
注意事項
注意事項
クラス インスタンスが書き込まれるときに、シリアル化コードで呼び出されます。
説明
注意事項
self を再ハッシュします。
要素を削除します。
説明
例
| 例 | |
{value
|| Declare and initialize a hash table with
|| String keys and int elements.
let price:{HashTable-of String, int} =
{new {HashTable-of String, int},
"apple", 56,
"banana", 87,
"cherry", 34
}
|| Remove the element at key "banana".
{price.remove "banana"}
|| Use a VBox to display the contents of price.
|| For each key in price, add a string to the VBox.
|| The string contains the relevant key and element.
|| Then display the VBox.
let message:VBox = {VBox}
{for key each-element:String in price do
{message.add each-element & " " & {price.get each-element}}
}
message
|| Note that the order of the elements in a hash
|| table is arbitrary.
}
|
注意事項
要素の値を設定します。
説明
例
| 例 | |
![]() | |
{value
|| Declare and initialize a hash table with
|| String keys and int elements.
let price:{HashTable-of String, int} =
{new {HashTable-of String, int},
"apple", 56,
"banana", 87,
"cherry", 34
}
|| Change the element at key "banana".
{price.set "banana", 72}
|| Add an element for "pear".
{price.set "pear", 62}
|| Use a VBox to display the contents of price.
|| For each key in price, add a string to the VBox.
|| The string contains the relevant key and element.
|| Then display the VBox.
let message:VBox = {VBox}
{for key each-element:String in price do
{message.add each-element & " " & {price.get each-element}}
}
message
|| Note that the order of the elements in a hash
|| table is arbitrary.
}
|
注意事項
self の要素を生成する
戻り値
例
| 例 | |
{value || Declare and initialize a hash table with
|| String keys and int elements
let h:{HashTable-of int, String} =
{new {HashTable-of int, String},
162094, "tom",
439853, "dick",
098627, "harry"
}
|| Create an Iterator-of from the hash table.
let my-iterator:{Iterator-of String} =
{h.to-Iterator}
|| Use a VBox to display the contents of my-iterator.
|| Iterate over the contents of my-iterator, adding
|| them to the VBox. Then display the VBox.
let message:VBox = {VBox}
{for each-element:String in my-iterator do
{message.add each-element}
}
message
}
|
注意事項
注意事項