public final class GenericUserPreferenceArray extends Object implements PreferenceArray
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.
| Constructor and Description |
|---|
GenericUserPreferenceArray(int size) |
GenericUserPreferenceArray(List<? extends Preference> prefs) |
| Modifier and Type | Method and Description |
|---|---|
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() |
finalize, getClass, notify, notifyAll, wait, wait, waitforEach, spliteratorpublic GenericUserPreferenceArray(int size)
public GenericUserPreferenceArray(List<? extends Preference> prefs)
public int length()
length in interface PreferenceArraypublic Preference get(int i)
get in interface PreferenceArrayi - indexPreference representation of the preference at ipublic void set(int i,
Preference pref)
PreferenceArrayPreferenceset in interface PreferenceArraypublic long getUserID(int i)
getUserID in interface PreferenceArrayi - indexpublic void setUserID(int i,
long userID)
setUserID in interface PreferenceArrayi - indexuserID - new user IDpublic long getItemID(int i)
getItemID in interface PreferenceArrayi - indexpublic void setItemID(int i,
long itemID)
PreferenceArraysetItemID in interface PreferenceArrayi - indexitemID - new item IDpublic long[] getIDs()
getIDs in interface PreferenceArraypublic float getValue(int i)
getValue in interface PreferenceArrayi - indexpublic void setValue(int i,
float value)
PreferenceArraysetValue in interface PreferenceArrayi - indexvalue - new preference valuepublic void sortByUser()
PreferenceArraysortByUser in interface PreferenceArraypublic void sortByItem()
PreferenceArraysortByItem in interface PreferenceArraypublic void sortByValue()
PreferenceArraysortByValue in interface PreferenceArraypublic void sortByValueReversed()
PreferenceArraysortByValueReversed in interface PreferenceArraypublic boolean hasPrefWithUserID(long userID)
hasPrefWithUserID in interface PreferenceArrayuserID - user IDpublic boolean hasPrefWithItemID(long itemID)
hasPrefWithItemID in interface PreferenceArrayitemID - item IDpublic GenericUserPreferenceArray clone()
clone in interface PreferenceArrayclone in class Objectpublic Iterator<Preference> iterator()
iterator in interface Iterable<Preference>Copyright © 2008–2017 The Apache Software Foundation. All rights reserved.