Solved

What collection should I use?

Posted on 2004-04-05
5
164 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
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
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 …
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 …
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:

763 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