當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。