aspose file tools
The moose likes Java in General and the fly likes suggest me a brief algorithm Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "suggest me a brief algorithm" Watch "suggest me a brief algorithm" New topic
Author

suggest me a brief algorithm

Saeed Talebi
Greenhorn

Joined: Jul 13, 2008
Posts: 2
Hi Dears,

i want to write an algorithm for sorting a HashMap in (iteration of each element)order. in fact, i have a big string (for example ,suppose the program reads a text file) and then i want to specify the 25 words which have the most iteration in file with the number of their iteration. i want to use a HashMap in this case. but when i want to implement the main algorithm, many ideas come to my mind which non of them are convenient.

please guide me.
best ragards, Saeed
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 35429
    
    9
Welcome to JavaRanch.

If I understand it correctly, then the keys of the Map are strings, and the values are the frequencies in which they occur? In that case, you can use a SortedMap instead of a HashMap. It keeps the elements in the natural order of their keys if you obtain an iterator from it.


Android appsImageJ pluginsJava web charts
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: suggest me a brief algorithm
 
Similar Threads
compund key algorithm for hashmap
Ordered and Sorted
help me out with this.
LinkedList vs ArrayList
How to Retrieve all Equal Objects from a List ?