当前位置: 首页>>代码示例>>Java>>正文


Java ObjIntConsumer.accept方法代码示例

本文整理汇总了Java中java.util.function.ObjIntConsumer.accept方法的典型用法代码示例。如果您正苦于以下问题:Java ObjIntConsumer.accept方法的具体用法?Java ObjIntConsumer.accept怎么用?Java ObjIntConsumer.accept使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util.function.ObjIntConsumer的用法示例。


在下文中一共展示了ObjIntConsumer.accept方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: eachWithIndex

import java.util.function.ObjIntConsumer; //导入方法依赖的package包/类
/** 
 * Iterates through an iterable type, passing each item and the item's index 
 * (a counter starting at zero) to the given consumer.
 */
public static <T> Object eachWithIndex(Iterable<T> receiver, ObjIntConsumer<T> consumer) {
    int count = 0;
    for (T t : receiver) {
        consumer.accept(t, count++);
    }
    return receiver;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:12,代码来源:Augmentation.java

示例2: forEachEntry

import java.util.function.ObjIntConsumer; //导入方法依赖的package包/类
@Override
public void forEachEntry(ObjIntConsumer<? super E> action) {
  checkNotNull(action);
  for (int i = 0; i < length; i++) {
    action.accept(elementSet.asList().get(i), getCount(i));
  }
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:8,代码来源:RegularImmutableSortedMultiset.java

示例3: makeInt

import java.util.function.ObjIntConsumer; //导入方法依赖的package包/类
/**
 * Constructs a {@code TerminalOp} that implements a mutable reduce on
 * {@code int} values.
 *
 * @param <R> The type of the result
 * @param supplier a factory to produce a new accumulator of the result type
 * @param accumulator a function to incorporate an int into an
 *        accumulator
 * @param combiner a function to combine an accumulator into another
 * @return A {@code ReduceOp} implementing the reduction
 */
public static <R> TerminalOp<Integer, R>
makeInt(Supplier<R> supplier,
        ObjIntConsumer<R> accumulator,
        BinaryOperator<R> combiner) {
    Objects.requireNonNull(supplier);
    Objects.requireNonNull(accumulator);
    Objects.requireNonNull(combiner);
    class ReducingSink extends Box<R>
            implements AccumulatingSink<Integer, R, ReducingSink>, Sink.OfInt {
        @Override
        public void begin(long size) {
            state = supplier.get();
        }

        @Override
        public void accept(int t) {
            accumulator.accept(state, t);
        }

        @Override
        public void combine(ReducingSink other) {
            state = combiner.apply(state, other.state);
        }
    }
    return new ReduceOp<Integer, R, ReducingSink>(StreamShape.INT_VALUE) {
        @Override
        public ReducingSink makeSink() {
            return new ReducingSink();
        }
    };
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:43,代码来源:ReduceOps.java

示例4: forEachEntry

import java.util.function.ObjIntConsumer; //导入方法依赖的package包/类
@Override
public void forEachEntry(ObjIntConsumer<? super E> action) {
  checkNotNull(action);
  for (int i = 0; i < size(); i++) {
    action.accept(elementSet.asList().get(i), getCount(i));
  }
}
 
开发者ID:paul-hammant,项目名称:googles-monorepo-demo,代码行数:8,代码来源:RegularImmutableSortedMultiset.java

示例5: setIndexes

import java.util.function.ObjIntConsumer; //导入方法依赖的package包/类
@SuppressWarnings("ValueOfIncrementOrDecrementUsed")
private <T> void setIndexes(T[] standings, Comparator<T> c, ObjIntConsumer<T> consumer) {
    Objects.requireNonNull(standings, "standings");
    Objects.requireNonNull(c, "c");
    Objects.requireNonNull(consumer, "consumer");
    int i = 0, len = standings.length, lastIndex = 0;

    for (T last = null, standing; i < len; last = standing) {
        standing = standings[i++];
        if (c.compare(standing, last) != 0) {
            lastIndex = i;
        }
        consumer.accept(standing, lastIndex);
    }
}
 
开发者ID:zjnu-acm,项目名称:judge,代码行数:16,代码来源:ContestService.java

示例6: forEach

import java.util.function.ObjIntConsumer; //导入方法依赖的package包/类
public static <T> void forEach(PrintStream out, List<T> items, ObjIntConsumer<T> fn) {
  int total = items.size();
  Debouncer msg = new Debouncer();
  for (int i = 0; i < total; i++) {
    fn.accept(items.get(i), i);
    if(msg.ready()) {
      out.println("-> "+msg.estimate(i, total));
    }
  }
  out.println("<> "+msg.estimate(total, total));
}
 
开发者ID:jjfiv,项目名称:chai,代码行数:12,代码来源:Debouncer.java

示例7: F

import java.util.function.ObjIntConsumer; //导入方法依赖的package包/类
F(ObjIntConsumer<T1> objIntConsumer) {
    this((BiFunction<T1, T2, R>) new BiFunction<T1, Integer, R>() {
        @Override
        public R apply(T1 t, Integer u) {
            objIntConsumer.accept(t, u);
            return null;
        }
    });
}
 
开发者ID:codebulb,项目名称:LambdaOmega,代码行数:10,代码来源:F.java

示例8: collect

import java.util.function.ObjIntConsumer; //导入方法依赖的package包/类
@Override
public <R> R collect(Supplier<R> supplier, ObjIntConsumer<R> accumulator, BiConsumer<R, R> combiner) {
    requireNonNull(supplier);
    requireNonNull(accumulator);
    final R value = supplier.get();
    accumulator.accept(value, element);
    // the combiner is never used in a non-parallell stream
    return value;
}
 
开发者ID:speedment,项目名称:speedment,代码行数:10,代码来源:SingletonIntStream.java

示例9: forEach

import java.util.function.ObjIntConsumer; //导入方法依赖的package包/类
@Override
public synchronized void forEach(ObjIntConsumer<LogEntry> function, int start_index, int end_index) {
    if(start_index < first_appended)
        start_index=first_appended;
    if(end_index > last_appended)
        end_index=last_appended;

    int start=Math.max(1, start_index)- first_appended, end=end_index- first_appended;
    for(int i=start; i <= end; i++) {
        LogEntry entry=entries[i];
        function.accept(entry, start_index);
        start_index++;
    }
}
 
开发者ID:belaban,项目名称:jgroups-raft,代码行数:15,代码来源:InMemoryLog.java

示例10: forEach

import java.util.function.ObjIntConsumer; //导入方法依赖的package包/类
@Override
public void forEach(ObjIntConsumer<LogEntry> function, int start_index, int end_index) {
    start_index = Math.max(start_index, Math.max(firstAppended,1));
    end_index = Math.min(end_index, lastAppended);

    for (int i=start_index; i<=end_index; i++) {
        LogEntry entry = getLogEntry(i);
        function.accept(entry, i);
    }
}
 
开发者ID:belaban,项目名称:jgroups-raft,代码行数:11,代码来源:LevelDBLog.java

示例11: forEachEntry

import java.util.function.ObjIntConsumer; //导入方法依赖的package包/类
@Override
public void forEachEntry(ObjIntConsumer<? super E> action) {
  checkNotNull(action);
  for (AvlNode<E> node = firstNode();
      node != header && node != null && !range.tooHigh(node.getElement());
      node = node.succ) {
    action.accept(node.getElement(), node.getCount());
  }
}
 
开发者ID:google,项目名称:guava,代码行数:10,代码来源:TreeMultiset.java

示例12: forEachEntry

import java.util.function.ObjIntConsumer; //导入方法依赖的package包/类
@Override
public void forEachEntry(ObjIntConsumer<? super E> action) {
  checkNotNull(action);
  for (int i = 0; i < enumConstants.length; i++) {
    if (counts[i] > 0) {
      action.accept(enumConstants[i], counts[i]);
    }
  }
}
 
开发者ID:google,项目名称:guava,代码行数:10,代码来源:EnumMultiset.java

示例13: forEachByIndex

import java.util.function.ObjIntConsumer; //导入方法依赖的package包/类
/**
 * Special forEach that takes an {@link ObjIntConsumer} which is provided the
 * value AND the index.
 *
 * @param aConsumer
 *        The consumer to use. May not be <code>null</code>.
 */
default void forEachByIndex (@Nonnull final ObjIntConsumer <? super ELEMENTTYPE> aConsumer)
{
  int nIndex = 0;
  for (final ELEMENTTYPE aItem : this)
  {
    aConsumer.accept (aItem, nIndex);
    ++nIndex;
  }
}
 
开发者ID:phax,项目名称:ph-commons,代码行数:17,代码来源:ICommonsIterable.java

示例14: _readUntilEOF

import java.util.function.ObjIntConsumer; //导入方法依赖的package包/类
private static void _readUntilEOF (@Nonnull @WillNotClose final InputStream aIS,
                                   @Nonnull final byte [] aBuffer,
                                   @Nonnull final ObjIntConsumer <? super byte []> aConsumer) throws IOException
{
  ValueEnforcer.notNull (aIS, "InputStream");
  ValueEnforcer.notNull (aBuffer, "Buffer");
  ValueEnforcer.notNull (aConsumer, "Consumer");

  int nBytesRead;
  // Potentially blocking read
  while ((nBytesRead = aIS.read (aBuffer, 0, aBuffer.length)) > -1)
    aConsumer.accept (aBuffer, nBytesRead);
}
 
开发者ID:phax,项目名称:ph-commons,代码行数:14,代码来源:StreamHelper.java

示例15: assertObjIntConsumer

import java.util.function.ObjIntConsumer; //导入方法依赖的package包/类
private <E extends Exception> void assertObjIntConsumer(ObjIntConsumer<Object> test, Class<E> type) {
    assertNotNull(test);
    try {
        test.accept(null, 0);
        fail();
    } 
    catch (Exception e) {
        assertException(type, e, "null:0");
    }
}
 
开发者ID:jOOQ,项目名称:jOOL,代码行数:11,代码来源:CheckedBiConsumerTest.java


注:本文中的java.util.function.ObjIntConsumer.accept方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。