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
Solved

What collection should I use?

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Android studio getdrawable(int) is deprecated 4 116
jdbc error in jsp application 20 63
servlet example 17 51
Running JavaFX on the Raspberry Pi 27 39
An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:

856 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