class interface HASH -- [V->STRING, K->STRING] creation make -- Create an empty dictionary. Internal storage capacity of the -- dictionary is initialized using the Default_size value. Then, -- tuning of needed storage capacity is performed automatically -- according to usage. If you are really sure that your dictionary -- is always really bigger than Default_size, you may consider to use -- with_capacity to save some execution time. ensure is_empty; capacity = Default_size from_tuple_table (table: ARRAY[TUPLE[K,V]]) -- not fully tested -- Create the dictionary from a TUPLE table. This -- code is untested and due to SmallEiffel limitations -- in the -0.74 Betas, probably will not work. require table /= Void and then table.count >= 1 from_table (table: COLLECTION[K]) -- Accept a 2D array that contains -- two entries, and create a HASH from them. -- the key is assumed to be the first entry. -- Example: -- create my_hash.from_table( << -- 1, 2, -- 3, 4, -- 5, 6 >> ) require valid_table: table /= Void and then table.count >= 2 and then table.count \\ 2 = 0 dbm_open (input_file_name: STRING) -- a simple-minded version of the dbmopen function -- from Perl. The input file is assumed to be a list -- of key/value pairs, each to its own line. The -- pairs are read in to create the HASH. -- if the input file doesn't exist, then an empty -- hash results. require input_file_name /= Void ensure file_name /= Void feature(s) from HASH make -- Create an empty dictionary. Internal storage capacity of the -- dictionary is initialized using the Default_size value. Then, -- tuning of needed storage capacity is performed automatically -- according to usage. If you are really sure that your dictionary -- is always really bigger than Default_size, you may consider to use -- with_capacity to save some execution time. ensure is_empty; capacity = Default_size dbm_open (input_file_name: STRING) -- a simple-minded version of the dbmopen function -- from Perl. The input file is assumed to be a list -- of key/value pairs, each to its own line. The -- pairs are read in to create the HASH. -- if the input file doesn't exist, then an empty -- hash results. require input_file_name /= Void ensure file_name /= Void feature(s) from HASH dbm_close -- close a hash created with dbm_open, writing out -- all entries. require file_name /= Void sorted_keys: ARRAY[STRING] -- Since sorted keys are quite popular, -- provide a feature for getting them easily. feature(s) from HASH file_name: STRING invariant capacity > 0; capacity >= count; cache_user.in_range(- 1,count); cache_user > 0 implies cache_node /= Void; cache_user > 0 implies cache_buckets.in_range(0,capacity - 1); end of HASH