net.sourceforge.atunes.utils
Class RankList<T>

java.lang.Object
  extended by net.sourceforge.atunes.utils.RankList<T>
All Implemented Interfaces:
java.io.Serializable

public class RankList<T>
extends java.lang.Object
implements java.io.Serializable

This class represents a Rank: a list of objects, every one with an associate counter. Objects are ordered by this counter. This class is used for statistics

See Also:
Serialized Form

Constructor Summary
RankList()
          Constructor.
 
Method Summary
 void addItem(T obj)
          Adds an object to rank.
 java.lang.Integer getCount(T obj)
          Returns count for a given object.
 java.util.List<java.lang.Integer> getNFirstElementCounts(int n)
          Returns the first n elements count of this rank.
 java.util.List<T> getNFirstElements(int n)
          Returns the first n elements of this rank.
 java.util.List<T> getOrder()
          Gets the order.
 void replaceItem(T oldItem, T newItem)
          Replaces an object, keeping order and count.
 int size()
          Return the size of rank.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RankList

public RankList()
Constructor.

Method Detail

addItem

public void addItem(T obj)
Adds an object to rank. If rank contains object, adds 1 to counter and updates rank order If not, adds object with count 1

Parameters:
obj - the obj

getCount

public java.lang.Integer getCount(T obj)
Returns count for a given object.

Parameters:
obj - the obj
Returns:
the count

getNFirstElementCounts

public java.util.List<java.lang.Integer> getNFirstElementCounts(int n)
Returns the first n elements count of this rank.

Parameters:
n - the n
Returns:
the n first element counts

getNFirstElements

public java.util.List<T> getNFirstElements(int n)
Returns the first n elements of this rank.

Parameters:
n - the n
Returns:
the n first elements

getOrder

public java.util.List<T> getOrder()
Gets the order.

Returns:
the order

replaceItem

public void replaceItem(T oldItem,
                        T newItem)
Replaces an object, keeping order and count.

Parameters:
oldItem - the old item
newItem - the new item

size

public int size()
Return the size of rank.

Returns:
the int


Copyright © 2006-2008 The aTunes Team. All Rights Reserved.