Getting the dictionary structure
In order to assist us with managing our dictionaries Tcl provides the dict info
command. The syntax is as follows:
dict info dictionaryValue
How to do it…
In the following example we will create a dictionary containing a key/value pair and then using the dict info
command obtain information for our dictionary. Return values from the commands are provided for clarity. Enter the following command:
% set names [dict create 1 John 2 Mary 3 Paul] 1 John 2 Mary 3 Paul % dict info $names 3 entries in table, 4 buckets number of buckets with 0 entries: 1 number of buckets with 1 entries: 3 number of buckets with 2 entries: 0 number of buckets with 3 entries: 0 number of buckets with 4 entries: 0 number of buckets with 5 entries: 0 number of buckets with 6 entries: 0 number of buckets with 7 entries: 0 number of buckets with 8 entries: 0 number of buckets with 9 entries: 0 number of buckets with 10 or more entries: 0 average search distance for entry: 1.0