|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.mahout.cf.taste.impl.model.GenericUserPreferenceArray
public final class GenericUserPreferenceArray
Like GenericItemPreferenceArray
but stores preferences for one user (all user IDs the same) rather
than one item.
This implementation maintains two parallel arrays, of item IDs and values. The idea is to save allocating
Preference
objects themselves. This saves the overhead of Preference
objects but also
duplicating the user ID value.
BooleanUserPreferenceArray
,
GenericItemPreferenceArray
,
GenericPreference
,
Serialized FormConstructor Summary | |
---|---|
GenericUserPreferenceArray(int size)
|
|
GenericUserPreferenceArray(List<? extends Preference> prefs)
|
Method Summary | |
---|---|
GenericUserPreferenceArray |
clone()
|
boolean |
equals(Object other)
|
Preference |
get(int i)
|
long[] |
getIDs()
|
long |
getItemID(int i)
|
long |
getUserID(int i)
|
float |
getValue(int i)
|
int |
hashCode()
|
boolean |
hasPrefWithItemID(long itemID)
|
boolean |
hasPrefWithUserID(long userID)
|
Iterator<Preference> |
iterator()
|
int |
length()
|
void |
set(int i,
Preference pref)
Sets preference at i from information in the given Preference |
void |
setItemID(int i,
long itemID)
Sets item ID for preference at i. |
void |
setUserID(int i,
long userID)
Sets user ID for preference at i. |
void |
setValue(int i,
float value)
Sets preference value for preference at i. |
void |
sortByItem()
Sorts underlying array by item ID, ascending. |
void |
sortByUser()
Sorts underlying array by user ID, ascending. |
void |
sortByValue()
Sorts underlying array by preference value, ascending. |
void |
sortByValueReversed()
Sorts underlying array by preference value, descending. |
String |
toString()
|
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public GenericUserPreferenceArray(int size)
public GenericUserPreferenceArray(List<? extends Preference> prefs)
Method Detail |
---|
public int length()
length
in interface PreferenceArray
public Preference get(int i)
get
in interface PreferenceArray
i
- index
Preference
representation of the preference at ipublic void set(int i, Preference pref)
PreferenceArray
Preference
set
in interface PreferenceArray
public long getUserID(int i)
getUserID
in interface PreferenceArray
i
- index
public void setUserID(int i, long userID)
setUserID
in interface PreferenceArray
i
- indexuserID
- new user IDpublic long getItemID(int i)
getItemID
in interface PreferenceArray
i
- index
public void setItemID(int i, long itemID)
PreferenceArray
setItemID
in interface PreferenceArray
i
- indexitemID
- new item IDpublic long[] getIDs()
getIDs
in interface PreferenceArray
public float getValue(int i)
getValue
in interface PreferenceArray
i
- index
public void setValue(int i, float value)
PreferenceArray
setValue
in interface PreferenceArray
i
- indexvalue
- new preference valuepublic void sortByUser()
PreferenceArray
sortByUser
in interface PreferenceArray
public void sortByItem()
PreferenceArray
sortByItem
in interface PreferenceArray
public void sortByValue()
PreferenceArray
sortByValue
in interface PreferenceArray
public void sortByValueReversed()
PreferenceArray
sortByValueReversed
in interface PreferenceArray
public boolean hasPrefWithUserID(long userID)
hasPrefWithUserID
in interface PreferenceArray
userID
- user ID
public boolean hasPrefWithItemID(long itemID)
hasPrefWithItemID
in interface PreferenceArray
itemID
- item ID
public GenericUserPreferenceArray clone()
clone
in interface PreferenceArray
clone
in class Object
public int hashCode()
hashCode
in class Object
public boolean equals(Object other)
equals
in class Object
public Iterator<Preference> iterator()
iterator
in interface Iterable<Preference>
public String toString()
toString
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |