Пример #1
0
 /**
  * Add a collection of IDs. The IDs are copied into the builder, not referenced.
  *
  * @param ids The IDs to add.
  * @return The builder (for chaining)
  */
 public ScoredIdListBuilder addAll(Iterable<ScoredId> ids) {
   Preconditions.checkState(ids != null, "builder has been finished");
   // fast iteration is safe since add() doesn't retain the id object
   for (ScoredId id : CollectionUtils.fast(ids)) {
     add(id);
   }
   return this;
 }
Пример #2
0
  @Override
  public LongSet getUsersForItem(long item) {
    List<Event> events = getEventsForItem(item);
    if (events == null) {
      return null;
    }

    LongSet users = new LongOpenHashSet();
    for (Event evt : CollectionUtils.fast(events)) {
      users.add(evt.getUserId());
    }
    return users;
  }
Пример #3
0
 @Override
 public ObjectCollection<Double> values() {
   return CollectionUtils.objectCollection(vector.values());
 }
Пример #4
0
 public void writeRatings(Iterable<? extends Rating> ratings) throws IOException {
   for (Rating r : CollectionUtils.fast(ratings)) {
     writeRating(r);
   }
 }