?
Solved

What collection should I use?

Posted on 2004-04-05
5
Medium Priority
?
167 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 150 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

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

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

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…
This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Suggested Courses
Course of the Month14 days, 1 hour left to enroll

801 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