// Утилитный метод, позволяющий получить массив рейтингов по массиву пользовательских id public double[] getRatingsForItemList(int[] userIds) { double[] ratings = new double[userIds.Length]; for (int i = 0; i < userIds.Length; i++) { GeneralRating r = getUserRating(userIds[i]); if (r == null) { throw new Exception("Item doesn't have rating by specified user id (" + "userId=" + userIds[i] + ", itemId=" + getId()); } ratings[i] = r.getRating(); } return(ratings); }
/* * Utility method to extract array of ratings based on array of item ids. */ public double[] getRatingsForItemList(int[] itemIds) { double[] ratings = new double[itemIds.Count()]; for (int i = 0, n = itemIds.Count(); i < n; i++) { GeneralRating r = getItemRating(itemIds[i]); if (r == null) { throw new Exception( "User doesn't have specified item id (" + "userId=" + UserId + ", itemId=" + itemIds[i]); } ratings[i] = r.getRating(); } return(ratings); }