CFEngine API

org.recommender.server
Class RatingArrays

java.lang.Object
  |
  +--org.recommender.server.RatingArrays

public class RatingArrays
extends java.lang.Object


Field Summary
 int[] ids
          Array of ids
 float[] ratings
          Array of ratings for ids in corresponding index in ids[]
 
Constructor Summary
RatingArrays(int size)
          Constructor for RatingArrays
RatingArrays(int[] ids, float[] ratings)
          Constructor for RatingArrays Note: arrays must be full of ids and ratings who's indexes correspond.
RatingArrays(int[] ids, float[] ratings, int incrementSize)
          Constructor for RatingArrays Note: arrays must be full of ids and ratings who's indexes correspond.
RatingArrays(int size, int incrementSize)
          Constructor for RatingArrays
 
Method Summary
 void addRating(int id, float rating)
          Add rating to arrays
 boolean containsKey(int id)
          Returns if array has key
 int[] getIds()
          Array of ids.
 int getIncrementSize()
          Size the arrays will increase once they reach threshold
 ItemRating[] getItemRatingsArray()
          Returns an array of itemratings corresponding to the values cached;
 int getLength()
          Returns the total number of valid elements in the array.
 float getRating(int id)
          Gets cached rating.
 float[] getRatings()
          Array of ratings.
 java.util.LinkedList getRatingsList()
          Builds a linkedlist of ItemRatings corresponding to values in the array
 void removeRating(int id)
          Remove rating from arrays
 void setIncrementSize(int incrementSize)
          Size the arrays will increase once they reach threshold
 java.lang.String toString()
          Prints out the arrays.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ids

public int[] ids
Array of ids


ratings

public float[] ratings
Array of ratings for ids in corresponding index in ids[]

Constructor Detail

RatingArrays

public RatingArrays(int size)
Constructor for RatingArrays

Parameters:
size - initial number of ratings to be stored

RatingArrays

public RatingArrays(int[] ids,
                    float[] ratings)
Constructor for RatingArrays Note: arrays must be full of ids and ratings who's indexes correspond. ** If you a group of ratings, this is much faster than adding them individually

Parameters:
ids - array containing ids
ratings - array of ratings corresponding to ids

RatingArrays

public RatingArrays(int size,
                    int incrementSize)
Constructor for RatingArrays

Parameters:
size - initial number of ratings to be stored
incrementSize - amount to increment array size by when it passes threshhold

RatingArrays

public RatingArrays(int[] ids,
                    float[] ratings,
                    int incrementSize)
Constructor for RatingArrays Note: arrays must be full of ids and ratings who's indexes correspond. ** If you a group of ratings, this is much faster than adding them individually

Parameters:
ids - array containing ids
ratings - array of ratings corresponding to ids
incrementSize - amount to increment array size by when it passes threshhold
Method Detail

addRating

public void addRating(int id,
                      float rating)
Add rating to arrays

Parameters:
id -
rating -

removeRating

public void removeRating(int id)
Remove rating from arrays

Parameters:
id -

getRating

public float getRating(int id)
Gets cached rating. If id does not exist, returns -999.

Parameters:
id -
Returns:

getIds

public int[] getIds()
Array of ids. **Note: to get the valid length of the array use RatingsArrays.length

Returns:
ids
See Also:
int getLength()

getRatings

public float[] getRatings()
Array of ratings. **Note: to get the valid length of the array use RatingsArrays.length

Returns:
ratings
See Also:
int getLength()

getLength

public int getLength()
Returns the total number of valid elements in the array. May be used similar to Array.length

Returns:
length

getIncrementSize

public int getIncrementSize()
Size the arrays will increase once they reach threshold

Returns:

setIncrementSize

public void setIncrementSize(int incrementSize)
Size the arrays will increase once they reach threshold

Parameters:
incrementSize -

toString

public java.lang.String toString()
Prints out the arrays.

Overrides:
toString in class java.lang.Object
Returns:

getRatingsList

public java.util.LinkedList getRatingsList()
Builds a linkedlist of ItemRatings corresponding to values in the array

Returns:

getItemRatingsArray

public ItemRating[] getItemRatingsArray()
Returns an array of itemratings corresponding to the values cached;

Returns:
ir

containsKey

public boolean containsKey(int id)
Returns if array has key

Parameters:
id -
Returns:

CFEngine API

Copyright © 2003 - Oregon State University www.orst.edu