org.apache.mahout.cf.taste.impl.model
Class BooleanUserPreferenceArray

java.lang.Object
  extended by org.apache.mahout.cf.taste.impl.model.BooleanUserPreferenceArray
All Implemented Interfaces:
Serializable, Cloneable, Iterable<Preference>, PreferenceArray

public final class BooleanUserPreferenceArray
extends Object
implements PreferenceArray

Like GenericUserPreferenceArray but stores, conceptually, BooleanPreference objects which have no associated preference value.

See Also:
BooleanPreference, BooleanItemPreferenceArray, GenericUserPreferenceArray, Serialized Form

Constructor Summary
BooleanUserPreferenceArray(int size)
           
BooleanUserPreferenceArray(List<? extends Preference> prefs)
           
 
Method Summary
 BooleanUserPreferenceArray 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

BooleanUserPreferenceArray

public BooleanUserPreferenceArray(int size)

BooleanUserPreferenceArray

public BooleanUserPreferenceArray(List<? extends Preference> prefs)
Method Detail

length

public int length()
Specified by:
length in interface PreferenceArray
Returns:
size of length of the "array"

get

public Preference get(int i)
Specified by:
get in interface PreferenceArray
Parameters:
i - index
Returns:
a materialized Preference representation of the preference at i

set

public void set(int i,
                Preference pref)
Description copied from interface: PreferenceArray
Sets preference at i from information in the given Preference

Specified by:
set in interface PreferenceArray

getUserID

public long getUserID(int i)
Specified by:
getUserID in interface PreferenceArray
Parameters:
i - index
Returns:
user ID from preference at i

setUserID

public void setUserID(int i,
                      long userID)
Sets user ID for preference at i. Note that this method will actually set the user ID for all preferences.

Specified by:
setUserID in interface PreferenceArray
Parameters:
i - index
userID - new user ID

getItemID

public long getItemID(int i)
Specified by:
getItemID in interface PreferenceArray
Parameters:
i - index
Returns:
item ID from preference at i

setItemID

public void setItemID(int i,
                      long itemID)
Description copied from interface: PreferenceArray
Sets item ID for preference at i.

Specified by:
setItemID in interface PreferenceArray
Parameters:
i - index
itemID - new item ID

getIDs

public long[] getIDs()
Specified by:
getIDs in interface PreferenceArray
Returns:
all item IDs

getValue

public float getValue(int i)
Specified by:
getValue in interface PreferenceArray
Parameters:
i - index
Returns:
preference value from preference at i

setValue

public void setValue(int i,
                     float value)
Description copied from interface: PreferenceArray
Sets preference value for preference at i.

Specified by:
setValue in interface PreferenceArray
Parameters:
i - index
value - new preference value

sortByUser

public void sortByUser()
Description copied from interface: PreferenceArray
Sorts underlying array by user ID, ascending.

Specified by:
sortByUser in interface PreferenceArray

sortByItem

public void sortByItem()
Description copied from interface: PreferenceArray
Sorts underlying array by item ID, ascending.

Specified by:
sortByItem in interface PreferenceArray

sortByValue

public void sortByValue()
Description copied from interface: PreferenceArray
Sorts underlying array by preference value, ascending.

Specified by:
sortByValue in interface PreferenceArray

sortByValueReversed

public void sortByValueReversed()
Description copied from interface: PreferenceArray
Sorts underlying array by preference value, descending.

Specified by:
sortByValueReversed in interface PreferenceArray

hasPrefWithUserID

public boolean hasPrefWithUserID(long userID)
Specified by:
hasPrefWithUserID in interface PreferenceArray
Parameters:
userID - user ID
Returns:
true if array contains a preference with given user ID

hasPrefWithItemID

public boolean hasPrefWithItemID(long itemID)
Specified by:
hasPrefWithItemID in interface PreferenceArray
Parameters:
itemID - item ID
Returns:
true if array contains a preference with given item ID

clone

public BooleanUserPreferenceArray clone()
Specified by:
clone in interface PreferenceArray
Overrides:
clone in class Object
Returns:
independent copy of this object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object other)
Overrides:
equals in class Object

iterator

public Iterator<Preference> iterator()
Specified by:
iterator in interface Iterable<Preference>

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2008–2014 The Apache Software Foundation. All rights reserved.