| parrotcode: Cardinal hash class and related functions | |
| Contents | Language Implementations | Cardinal |

src/classes/CardinalHash.pir - Cardinal hash class and related functions

Pair(key, value)
block once for each item in self,
with the key and value passed as args.

our List multi method Hash::delete ( *@keys ) our Scalar multi method Hash::delete ( $key ) is defaultDeletes the elements specified by
$key or $keys from the invocant. returns the value(s) that were associated to those keys.
our Bool multi method Hash::exists ( $key )True if invocant has an element whose key matches
$key, false otherwise.
multi Int|List Hash::keys ( %hash : MatchTest *@keytests ) multi Int|List Hash::kv ( %hash : MatchTest *@keytests ) multi Int|(List of Pair) Hash::pairs (%hash : MatchTest *@keytests ) multi Int|List Hash::values ( %hash : MatchTest *@keytests )Iterates the elements of
%hash in no apparent order, but the order will be the same between successive calls to these functions, as long as %hash doesn't change.If @keytests are provided, only elements whose keys evaluate $key ~~ any(@keytests) as true are iterated.What is returned at each element of the iteration varies with function. keys only returns the key; values the value; kv returns both as a 2 element list in (key, value) order, pairs a Pair(key, value).Note that kv %hash returns the same as zip(keys %hash; values %hash)In Scalar context, they all return the count of elements that would have been iterated.The lvalue form of keys is not longer supported. Use the .buckets property instead.
|
|
|