Solved

What collection should I use?

Posted on 2004-04-05
5
165 Views
Last Modified: 2010-03-31
Hi,

I am trying to create a simple search engine and have got a crawler working that stores information of pages into a database. After the user inputs their search times I pull information out of the database and rank it with a certain algorithm. My question is this, I need to record certain information about ranking so I can produce the results ordered by their score. What woud be the best way to do this? I need title, description page and score to be stored for each page and for this information to be presented to me in order of score (highest to lowest).

Thanks in advance.
0
Comment
Question by:jambo69
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 
LVL 37

Accepted Solution

by:
zzynx earned 50 total points
ID: 10758229
>>  I need title, description page and score to be stored
Make a class X that can store this information
Make sure it implements the Comparable interface
( i.e. implement compareTo() )
Your compareTo() function must compare the scores of the X objects

Than you can store your X objects in a List, sort it (using you compareTo() function), and than output the sorted List.

0
 
LVL 37

Expert Comment

by:zzynx
ID: 10758241
>> sort it (using you compareTo() function)
= simply perform:
Collections.sort(yourList_of_X_objects);
0
 
LVL 13

Expert Comment

by:Webstorm
ID: 10758525
You can use a TreeSet : all elements are always sorted.

http://java.sun.com/j2se/1.4.2/docs/api/java/util/TreeSet.html

0
 
LVL 16

Expert Comment

by:warturtle
ID: 10759353
Hi,

I think you could use LinkedList collection classes, and HashMaps along with it for faster data accesses.

http://java.sun.com/j2se/1.4.2/docs/api/

Regards,

Warturtle
0
 
LVL 37

Expert Comment

by:zzynx
ID: 10765935
Thanks for accepting.
That keeps us answering your questions in the future.
;°)
0

Featured Post

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
hibernate example issues from command prompt 10 85
JavaFX TableView not displaying correctly 3 154
jsp error 6 70
listing all the respondents to a twitter feed - Java 5 44
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
The viewer will learn how to implement Singleton Design Pattern in Java.
Suggested Courses

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question