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


Java BiConsumer.accept方法代码示例

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


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

示例1: find

import java.util.function.BiConsumer; //导入方法依赖的package包/类
/**
 * Finds the closest node or edges within the specified maximum radius.
 *
 * @param x          the x position of the query point
 * @param y          the y position of the query point
 * @param nodeAction the action that needs to be executed when a node is found
 * @param edgeAction the action that needs to be executed when an edge is found
 */
@SuppressWarnings("squid:S1166") // No need to log the exception itself, a message is enough.
public void find(final double x, final double y,
                 final Consumer<Integer> nodeAction, final BiConsumer<Integer, Integer> edgeAction) {
    try {
        final Entry<Integer[], Geometry> result = tree.nearest(point(x, y), MAX_NEARNESS_DISTANCE, 1)
                .toBlocking()
                .first();

        if (result.geometry() instanceof Rectangle) {
            nodeAction.accept(result.value()[0]);
        } else if (result.geometry() instanceof Line) {
            edgeAction.accept(result.value()[0], result.value()[1]);
        }
    } catch (final NoSuchElementException e) {
        // There is no need to log the exception itself.
        LOGGER.debug("No node or edge found at position (" + x + ", " + y + ").");
    }
}
 
开发者ID:ProgrammingLife2017,项目名称:hygene,代码行数:27,代码来源:RTree.java

示例2: runAlert

import java.util.function.BiConsumer; //导入方法依赖的package包/类
public static void runAlert(BiConsumer<Stage, AlertWindowController> setup) {
    try {
        // JavaFX2 doesn't actually have a standard alert template. Instead the Scene Builder app will create FXML
        // files for an alert window for you, and then you customise it as you see fit. I guess it makes sense in
        // an odd sort of way.
        Stage dialogStage = new Stage();
        dialogStage.initModality(Modality.APPLICATION_MODAL);
        FXMLLoader loader = new FXMLLoader(GuiUtils.class.getResource("alert.fxml"));
        Pane pane = loader.load();
        AlertWindowController controller = loader.getController();
        setup.accept(dialogStage, controller);
        dialogStage.setScene(new Scene(pane));
        dialogStage.showAndWait();
    } catch (IOException e) {
        // We crashed whilst trying to show the alert dialog (this should never happen). Give up!
        throw new RuntimeException(e);
    }
}
 
开发者ID:creativechain,项目名称:creacoinj,代码行数:19,代码来源:GuiUtils.java

示例3: testWriteLock_lockUnlock

import java.util.function.BiConsumer; //导入方法依赖的package包/类
/**
 * write-locking, then unlocking, an unlocked lock succeed
 */
public void testWriteLock_lockUnlock() {
    StampedLock lock = new StampedLock();

    for (Function<StampedLock, Long> writeLocker : writeLockers())
    for (BiConsumer<StampedLock, Long> writeUnlocker : writeUnlockers()) {
        assertFalse(lock.isWriteLocked());
        assertFalse(lock.isReadLocked());
        assertEquals(0, lock.getReadLockCount());

        long s = writeLocker.apply(lock);
        assertValid(lock, s);
        assertTrue(lock.isWriteLocked());
        assertFalse(lock.isReadLocked());
        assertEquals(0, lock.getReadLockCount());
        writeUnlocker.accept(lock, s);
        assertUnlocked(lock);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:22,代码来源:StampedLockTest.java

示例4: forEach

import java.util.function.BiConsumer; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public synchronized void forEach(BiConsumer<? super K, ? super V> action) {
    Objects.requireNonNull(action);     // explicit check required in case
                                        // table is empty.
    final int expectedModCount = modCount;

    Entry<?, ?>[] tab = table;
    for (Entry<?, ?> entry : tab) {
        while (entry != null) {
            action.accept((K)entry.key, (V)entry.value);
            entry = entry.next;

            if (expectedModCount != modCount) {
                throw new ConcurrentModificationException();
            }
        }
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:20,代码来源:Hashtable.java

示例5: forEach

import java.util.function.BiConsumer; //导入方法依赖的package包/类
public void forEach(BiConsumer<? super K, ? super V> action) {
    if (action == null)
        throw new NullPointerException();
    int mc = modCount;
    for (LinkedHashMap.Entry<K,V> e = head; e != null; e = e.after)
        action.accept(e.key, e.value);
    if (modCount != mc)
        throw new ConcurrentModificationException();
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:10,代码来源:LinkedHashMap.java

示例6: pullEach

import java.util.function.BiConsumer; //导入方法依赖的package包/类
public static <T> CompletableSubscriber<T> pullEach(BiConsumer<T, Subscription> consumer) {
  return new AbstractCompletableSubscriber<T>() {

    @Override
    public void onSubscribe(Subscription subscription) {
      super.onSubscribe(subscription);
      subscription.request(1);
    }

    @Override
    public void onNext(T item) {
      consumer.accept(item, subscription);
    }
  };
}
 
开发者ID:openknowledge,项目名称:reactive-jax-rs,代码行数:16,代码来源:CompletableSubscriber.java

示例7: forEachPropertyPair

import java.util.function.BiConsumer; //导入方法依赖的package包/类
@Override
public void forEachPropertyPair(AbstractBlockBase<?> block, BiConsumer<String, String> action) {
    if (get(Flags.SUBTREE, block) && (block.getDominator() == null || !get(Flags.SUBTREE, block.getDominator()))) {
        action.accept("hasDefinition", "true");
    }
    super.forEachPropertyPair(block, action);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:8,代码来源:ConstantTree.java

示例8: forEach

import java.util.function.BiConsumer; //导入方法依赖的package包/类
@Override
public void forEach(BiConsumer<? super K, ? super V> action) {
  checkNotNull(action);
  for (Entry<K, V> entry : entries) {
    action.accept(entry.getKey(), entry.getValue());
  }
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:8,代码来源:RegularImmutableBiMap.java

示例9: getAllUniforms

import java.util.function.BiConsumer; //导入方法依赖的package包/类
public static void getAllUniforms(int program, BiConsumer<Integer,String> dest){
	glUseProgram(program);
	
	int id=0;
	String name,last="";
	while(!(name=glGetActiveUniform(program, id, 512)).isEmpty()){
		if(last.equals(name)) break;
		dest.accept(id, last=name);
		id++;
	}
}
 
开发者ID:LapisSea,项目名称:OpenGL-Bullet-engine,代码行数:12,代码来源:GLUtil.java

示例10: test

import java.util.function.BiConsumer; //导入方法依赖的package包/类
static <E> void test(Queue<E> queue, Supplier<E> supplier,
                     BiConsumer<? super Queue<E>, Throwable> checker) {
    Throwable x = null;
    try { queue.add(supplier.get()); }
    catch (Throwable e) { x = e; }
    checker.accept(queue, x);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:8,代码来源:AddNonComparable.java

示例11: createList

import java.util.function.BiConsumer; //导入方法依赖的package包/类
public static <V extends DoublyLinkedPanel<V>> void createList(int count, Function<Integer, V> constructor, BiConsumer<Integer,V> forEach){
	V prevField = null;
	for(int i = 0; i<count; i++){
		V newField = constructor.apply(i);
		forEach.accept(i, newField);
		DoublyLinkedPanel.link(prevField, newField);
		prevField = newField;
	}
}
 
开发者ID:Emoun,项目名称:racp,代码行数:10,代码来源:DoublyLinkedPanel.java

示例12: exec

import java.util.function.BiConsumer; //导入方法依赖的package包/类
/**
 * @param list
 * @param fnEach
 * @param <V>
 */
static <V> void exec(final List<V> list,
                     final BiConsumer<V, Integer> fnEach) {
    final int size = list.size();
    for (int idx = Values.IDX; idx < size; idx++) {
        final V item = list.get(idx);
        if (null != item) {
            fnEach.accept(item, idx);
        }
    }
}
 
开发者ID:silentbalanceyh,项目名称:vertx-zero,代码行数:16,代码来源:Congregation.java

示例13: testTryUnlockWrite_failure

import java.util.function.BiConsumer; //导入方法依赖的package包/类
/**
 * tryUnlockWrite fails if not write locked
 */
public void testTryUnlockWrite_failure() {
    StampedLock lock = new StampedLock();
    assertFalse(lock.tryUnlockWrite());

    for (Function<StampedLock, Long> readLocker : readLockers())
    for (BiConsumer<StampedLock, Long> readUnlocker : readUnlockers()) {
        long s = assertValid(lock, readLocker.apply(lock));
        assertFalse(lock.tryUnlockWrite());
        assertTrue(lock.isReadLocked());
        readUnlocker.accept(lock, s);
        assertUnlocked(lock);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:17,代码来源:StampedLockTest.java

示例14: forEach

import java.util.function.BiConsumer; //导入方法依赖的package包/类
@Override
public void forEach(BiConsumer<? super K, ? super V> action) {
    Objects.requireNonNull(action);
    int expectedModCount = modCount;
    for (Entry<K, V> e = getFirstEntry(); e != null; e = successor(e)) {
        action.accept(e.key, e.value);

        if (expectedModCount != modCount) {
            throw new ConcurrentModificationException();
        }
    }
}
 
开发者ID:dmcmanam,项目名称:bbst-showdown,代码行数:13,代码来源:TreeMapBST.java

示例15: forEachWithIndex

import java.util.function.BiConsumer; //导入方法依赖的package包/类
/**
 * 带序号迭代元组
 *
 * @param action 带序号的迭代函数
 */
public final void forEachWithIndex(final BiConsumer<Integer, ? super Object> action) {
    requireNonNull(action, "action is null");
    for (int i = 0, length = this.valueList.size(); i < length; i++)
        action.accept(i, this.valueList.get(i));
}
 
开发者ID:sd4324530,项目名称:JTuple,代码行数:11,代码来源:Tuple.java


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