469,357 Members | 1,593 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,357 developers. It's quick & easy.

Help with Eiffel program please

I can't seem to get my program to setup the hashed dictionary correctly. It seems to keep the last entry in, and references every key to that entry.

Expand|Select|Wrap|Line Numbers
  1. dictsetup(h:HASHED_DICTIONARY [HASHED_SET[STRING], STRING]; fname:STRING) is
  2.         local
  3.             in_file: TEXT_FILE_READ;
  4.             t, t0: STRING
  5.         do
  6.             from
  7.                 !!in_file.connect_to(fname)
  8.                 !!set.make
  9.             until
  10.                 in_file.end_of_input
  11.             loop
  12.                 in_file.read_word
  13.                 t := in_file.last_string
  14.                 t.to_lower
  15.  
  16.                 t0 := t.twin
  17.                 sortstring(t0)
  18.  
  19.                 if h.has(t0) then
  20.                     h.at(t0).add(t)
  21.                 else
  22.                     set.clear_count
  23.                     set.add(t)
  24.                     h.put(set,t0)
  25.                 end
  26.  
  27.  
  28.             end
  29.             in_file.disconnect
  30.         end
  31.  
I want the method to take in each word from the file, get a sorted version of that word and add it to the dictionary. It gets added in a set of words that have the same key (sorted version). If the sorted version of the word has been met before then we add it to the set referenced by that word, else we create a new set with that word and add it to the dictionary with the sorted word as a key.

Help needed urgently :(
Dec 16 '10 #1
0 1149

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by Roy J | last post: by
1 post views Thread by Brent W. Hughes | last post: by
4 posts views Thread by kirill_uk | last post: by
1 post views Thread by apacheutara | last post: by
5 posts views Thread by ToAsTeEJaVa | last post: by
6 posts views Thread by André | last post: by
5 posts views Thread by sandyw | last post: by
5 posts views Thread by mohammaditraders | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.