Exemplo n.º 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;
 }
Exemplo n.º 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;
  }
Exemplo n.º 3
0
 @Override
 public ObjectCollection<Double> values() {
   return CollectionUtils.objectCollection(vector.values());
 }
Exemplo n.º 4
0
 public void writeRatings(Iterable<? extends Rating> ratings) throws IOException {
   for (Rating r : CollectionUtils.fast(ratings)) {
     writeRating(r);
   }
 }