## org.apache.mahout.cf.taste.model
Interface PreferenceArray

All Superinterfaces:
  Cloneable, Iterable<Preference>, Serializable

All Known Implementing Classes:
  BooleanItemPreferenceArray, BooleanUserPreferenceArray, GenericItemPreferenceArray, GenericUserPreferenceArray

    public interface PreferenceArray

extends Cloneable, Serializable, Iterable<Preference>

An alternate representation of an array of `Preference`. Implementations, in theory, can produce a more memory-efficient representation.

Method Summary
`PreferenceArray` `clone()`
`Preference` `get(int i)`
`long[]` `getIDs()`
`long` `getItemID(int i)`
`long` `getUserID(int i)`
`float` `getValue(int i)`
`boolean` `hasPrefWithItemID(long itemID)`
`boolean` `hasPrefWithUserID(long userID)`
`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.

Methods inherited from interface java.lang.Iterable
`iterator`

Method Detail

### length

    int length()

  Returns:
    size of length of the "array"

### get

    Preference get(int i)

  Parameters:
    `i` - index
  Returns:
    a materialized `Preference` representation of the preference at i

### set

    void set(int i,
             Preference pref)

  Sets preference at i from information in the given `Preference`

  Parameters:
    `i` -
    `pref` -

### getUserID

    long getUserID(int i)

  Parameters:
    `i` - index
  Returns:
    user ID from preference at i

### setUserID

    void setUserID(int i,
                   long userID)

  Sets user ID for preference at i.

  Parameters:
    `i` - index
    `userID` - new user ID

### getItemID

    long getItemID(int i)

  Parameters:
    `i` - index
  Returns:
    item ID from preference at i

### setItemID

    void setItemID(int i,
                   long itemID)

  Sets item ID for preference at i.

  Parameters:
    `i` - index
    `itemID` - new item ID

### getIDs

    long[] getIDs()

  Returns:
    all user or item IDs

### getValue

    float getValue(int i)

  Parameters:
    `i` - index
  Returns:
    preference value from preference at i

### setValue

    void setValue(int i,
                  float value)

  Sets preference value for preference at i.

  Parameters:
    `i` - index
    `value` - new preference value

### clone

    PreferenceArray clone()

  Returns:
    independent copy of this object

### sortByUser

    void sortByUser()

  Sorts underlying array by user ID, ascending.

### sortByItem

    void sortByItem()

  Sorts underlying array by item ID, ascending.

### sortByValue

    void sortByValue()

  Sorts underlying array by preference value, ascending.

### sortByValueReversed

    void sortByValueReversed()

  Sorts underlying array by preference value, descending.

### hasPrefWithUserID

    boolean hasPrefWithUserID(long userID)

  Parameters:
    `userID` - user ID
  Returns:
    true if array contains a preference with given user ID

### hasPrefWithItemID

    boolean hasPrefWithItemID(long itemID)

  Parameters:
    `itemID` - item ID
  Returns:
    true if array contains a preference with given item ID

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