## org.apache.mahout.cf.taste.impl.model
Class BooleanItemPreferenceArray

    java.lang.Object
      org.apache.mahout.cf.taste.impl.model.BooleanItemPreferenceArray

All Implemented Interfaces:
  Serializable, Cloneable, Iterable<Preference>, PreferenceArray

    public final class BooleanItemPreferenceArray

extends Object
implements PreferenceArray

Like `BooleanUserPreferenceArray` but stores preferences for one item (all item IDs the same) rather than one user.

See Also:
  `BooleanPreference`, `BooleanUserPreferenceArray`, `GenericItemPreferenceArray`, Serialized Form

Constructor Summary
`BooleanItemPreferenceArray(int size)`
`BooleanItemPreferenceArray(List<? extends Preference> prefs, boolean forOneUser)`

Method Summary
`BooleanItemPreferenceArray` `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

### BooleanItemPreferenceArray

    public BooleanItemPreferenceArray(int size)

### BooleanItemPreferenceArray

    public BooleanItemPreferenceArray(List<? extends Preference> prefs,
                                      boolean forOneUser)

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)

  Description copied from interface: `PreferenceArray`
  Sets user ID for preference at i.

  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)

  Sets item ID for preference at i. Note that this method will actually set the item ID for all preferences.

  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 user 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 BooleanItemPreferenceArray 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.