Solved

What collection should I use?

Posted on 2004-04-05
5
160 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
  • 3
5 Comments
 
LVL 37

Accepted Solution

by:
zzynx earned 50 total points
Comment Utility
>>  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
Comment Utility
>> sort it (using you compareTo() function)
= simply perform:
Collections.sort(yourList_of_X_objects);
0
 
LVL 13

Expert Comment

by:Webstorm
Comment Utility
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
Comment Utility
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
Comment Utility
Thanks for accepting.
That keeps us answering your questions in the future.
;°)
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
This video teaches viewers about errors in exception handling.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

772 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now