com.knowledgebooks.utils
Class ScoredList

java.lang.Object
  extended by com.knowledgebooks.utils.ScoredList

public class ScoredList
extends java.lang.Object

Copyright 2002-2008 by Mark Watson. All rights reserved.

This software is not public domain. It can be legally used under either of the following licenses:

1. KnowledgeBooks.com Non Commercial Royality Free License
2. KnowledgeBooks.com Commercial Use License

see www.knowledgebooks.com for details


Constructor Summary
ScoredList()
          Create an empty scored list
ScoredList(int max_to_keep)
           
 
Method Summary
 boolean addValue(java.lang.String text)
          Add a value to a scored list.
 boolean addValue(java.lang.String text, int score)
          Add a value to a scored list
 boolean contains(java.lang.String s)
          Determine if a scored list contains a value string
 int getScore(int index)
          Get a specific score
 java.lang.String getValue(int index)
          Get a specific value
 java.lang.String getValuesAsString()
          Get all values and scores as a human readable string
 java.lang.String getValuesAsString(int max_return_values)
          Get a specified number of values as a human readable string
 int size()
          Determing the number of values in a scored list
 void sort()
          Sort a scored list in highest value first order
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ScoredList

public ScoredList(int max_to_keep)

ScoredList

public ScoredList()
Create an empty scored list

Method Detail

addValue

public boolean addValue(java.lang.String text,
                        int score)
Add a value to a scored list

Parameters:
text -
score -
Returns:
true is a value was added. If the score is lower than all currently stored values and the maximum number of values to store has been reached, then the value will not be stored and the return value will be false.

addValue

public boolean addValue(java.lang.String text)
Add a value to a scored list. The "score" is not specified so the "score" for a given value string is the number of times that it is added to the scored list.

Parameters:
text -
Returns:
true is a value was added. If the score is lower than all currently stored values and the maximum number of values to store has been reached, then the value will not be stored and the return value will be false.

contains

public boolean contains(java.lang.String s)
Determine if a scored list contains a value string

Parameters:
s -
Returns:
true if the value is stored in the scored list

sort

public void sort()
Sort a scored list in highest value first order


size

public int size()
Determing the number of values in a scored list

Returns:
the size of the scored list

getValue

public java.lang.String getValue(int index)
Get a specific value

Parameters:
index -
Returns:
the value at the specified index

getScore

public int getScore(int index)
Get a specific score

Parameters:
index -
Returns:
the score at the specified index

getValuesAsString

public java.lang.String getValuesAsString()
Get all values and scores as a human readable string

Returns:
string

getValuesAsString

public java.lang.String getValuesAsString(int max_return_values)
Get a specified number of values as a human readable string

Parameters:
max_return_values -
Returns:
string