當前位置: 首頁>>代碼示例>>Java>>正文


Java Arrays.stream方法代碼示例

本文整理匯總了Java中java.util.Arrays.stream方法的典型用法代碼示例。如果您正苦於以下問題:Java Arrays.stream方法的具體用法?Java Arrays.stream怎麽用?Java Arrays.stream使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.util.Arrays的用法示例。


在下文中一共展示了Arrays.stream方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testFlattenTree

import java.util.Arrays; //導入方法依賴的package包/類
/**
 * Test flattening a tree.
 *
 * Each node has a String value, and they will be organized as:
 *
 * <pre>
 *     A
 *    / \
 *   B   C
 *  /|   |\
 * D E   F G
 * </pre>
 *
 * In-order, depth-first visiting should give the following sequence:<br>
 * A -> B -> D -> E -> C -> F -> G
 */
@Test
public void testFlattenTree() {
    /* Prepare the tree */
    TreeNode nodeD = new TreeNode(new TreeNode[0], "D");
    TreeNode nodeE = new TreeNode(new TreeNode[0], "E");
    TreeNode nodeF = new TreeNode(new TreeNode[0], "F");
    TreeNode nodeG = new TreeNode(new TreeNode[0], "G");
    TreeNode nodeB = new TreeNode(new TreeNode[] {nodeD, nodeE}, "B");
    TreeNode nodeC = new TreeNode(new TreeNode[] {nodeF, nodeG}, "C");
    TreeNode nodeA = new TreeNode(new TreeNode[] {nodeB, nodeC}, "A");

    /* Run the test */
    StreamFlattener<TreeNode> sf = new StreamFlattener<>(node -> Arrays.stream(node.getChildren()));

    List<String> expected = Arrays.asList("A", "B", "D", "E", "C", "F", "G");
    List<String> results = sf.flatten(nodeA).map(TreeNode::getValue).collect(Collectors.toList());

    assertEquals(expected, results);
}
 
開發者ID:lttng,項目名稱:lttng-scope,代碼行數:36,代碼來源:StreamFlattenerTest.java

示例2: mirror

import java.util.Arrays; //導入方法依賴的package包/類
public QuadBuilder mirror() {
	if(facingMap.containsKey(last)) {
		Stream<Vector3> stream = Arrays.stream(facingMap.get(last).getVectors());
		switch(last) {
			case DOWN:
			case UP:
				stream.forEach(vec -> {
					vec.subtract(0.5D).rotate(EnumFacing.Axis.Y, 180).add(0.5D);
				});
				break;
			case NORTH:
			case SOUTH:
				stream.forEach(vec -> {
					vec.subtract(0.5D).rotate(EnumFacing.Axis.X, 180).add(0.5D);
				});
				break;
			case EAST:
			case WEST:
				stream.forEach(vec -> {
					vec.subtract(0.5D).rotate(EnumFacing.Axis.Z, 180).add(0.5D);
				});
				break;
		}
	}
	return this;
}
 
開發者ID:ArekkuusuJerii,項目名稱:Solar,代碼行數:27,代碼來源:QuadBuilder.java

示例3: generatePopupPreviewDithers

import java.util.Arrays; //導入方法依賴的package包/類
/**
 * Draws a set of dithers, derived from the provided image, onto the popup
 * preview frame
 *
 * @param image   the image to apply the dithers to
 * @param dithers the dither strategies to apply
 * @throws InterruptedException if the processing is interrupted
 */
private <T extends DitherStrategy> void generatePopupPreviewDithers(Image image, @SuppressWarnings("unchecked") T... dithers) throws InterruptedException {
    Stream<T> stream = Arrays.stream(dithers);
    Runnable runnable = () -> {
        stream.forEach(dither -> {
            WorkContainer workContainer = workDispatcher.submitPopupPreview(image, dither);
            Optional<ResultImage> resultImage = ResultImage.getFinalImage(workContainer.getResultImage());
            if (!resultImage.isPresent()) {
                log.error("Unable to get final image for preview");
                return;
            }
            ImageHelper.copyImage(resultImage.get().getImage(), PopupPreviewFrame.getPreviewImage(), PopupPreviewFrame.getPoint());
            PopupPreviewFrame.repaintImage();
        });
    };
    exec.submit(runnable);
}
 
開發者ID:KodeMunkie,項目名稱:imagetozxspec,代碼行數:25,代碼來源:WorkManager.java

示例4: appendStackTrace

import java.util.Arrays; //導入方法依賴的package包/類
private void appendStackTrace(StringBuilder log, ThrowableProxy proxy) {
    if (proxy != null) {
        Stream<StackTraceElementProxy> trace = Arrays.stream(proxy.getStackTraceElementProxyArray());

        trace.forEach(step -> {
            String string = step.toString();

            log.append(CoreConstants.TAB).append(string);

            ThrowableProxyUtil.subjoinPackagingData(log, step);

            log.append(CoreConstants.LINE_SEPARATOR);
        });

        trace.close();
    }
}
 
開發者ID:hmcts,項目名稱:java-logging,代碼行數:18,代碼來源:ReformLoggingLayout.java

示例5: format

import java.util.Arrays; //導入方法依賴的package包/類
private String format(EditorSetting ed) {
    if (ed == BUILT_IN_EDITOR) {
        return "-default";
    } else {
        Stream<String> elems = Arrays.stream(ed.cmd);
        if (ed.wait) {
            elems = Stream.concat(Stream.of("-wait"), elems);
        }
        return elems.collect(joining(" "));
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:12,代碼來源:JShellTool.java

示例6: getArrayData

import java.util.Arrays; //導入方法依賴的package包/類
public void getArrayData(){
	int[] ages = {24, 33, 21, 22, 45};
	IntStream ageStream = Arrays.stream(ages);
	
	double[] salaries = {33000.50, 23100.20, 45000.50};
	DoubleStream salStream = Arrays.stream(salaries);
	
	long[] longDates = {23434432342L, 11123343435L, 34343342343L};
	LongStream dateStream = Arrays.stream(longDates);
}
 
開發者ID:PacktPublishing,項目名稱:Spring-5.0-Cookbook,代碼行數:11,代碼來源:EmployeeStreamService.java

示例7: supply

import java.util.Arrays; //導入方法依賴的package包/類
@Override
public Stream<SuppliedParticle> supply(int tick) {
    if (tick % appearingInterval == 0) {
        return Arrays.stream(particles);
    } else {
        return Stream.of();
    }
}
 
開發者ID:devcexx,項目名稱:libtrails,代碼行數:9,代碼來源:CircumferenceSupplier.java

示例8: fileStream

import java.util.Arrays; //導入方法依賴的package包/類
/**
 * Create a stream of files from a directory.
 *
 * @param dir The {@code File} that hopefully is a directory.
 * @return A stream of {@code File}s.
 */
public static Stream<File> fileStream(File dir) {
    File[] files;
    return (dir == null || !dir.isDirectory()
        || (files = dir.listFiles()) == null)
        ? Stream.<File>empty()
        : Arrays.stream(files);
}
 
開發者ID:wintertime,項目名稱:FreeCol,代碼行數:14,代碼來源:CollectionUtils.java

示例9: supply

import java.util.Arrays; //導入方法依賴的package包/類
@Override
public Stream<SuppliedParticle> supply(int tick) {
    if (tick % appearingInterval == 0) {
        return Arrays.stream(particles, 0, allocatedPixels);
    } else {
        return Stream.of();
    }
}
 
開發者ID:devcexx,項目名稱:libtrails,代碼行數:9,代碼來源:BitmapSupplier.java

示例10: constructor

import java.util.Arrays; //導入方法依賴的package包/類
public static Stream<Constructor> constructor(Class<?> cls) {
  return Arrays.stream(cls.getDeclaredConstructors());
}
 
開發者ID:btk5h,項目名稱:skript-mirror,代碼行數:4,代碼來源:Util.java

示例11: getAnnotationAttributes

import java.util.Arrays; //導入方法依賴的package包/類
private static List<Method> getAnnotationAttributes(Class<? extends Annotation> type) {
    Stream<Method> methods = Arrays.stream(type.getDeclaredMethods());
    List<Method> results = methods.filter(AnnotationUtils::isAttributeMethod).collect(Collectors.toList());
    results.forEach(r -> r.setAccessible(true));
    return results;
}
 
開發者ID:sdadas,項目名稱:spring2ts,代碼行數:7,代碼來源:AnnotationUtils.java

示例12: attachToPropertySubGroup

import java.util.Arrays; //導入方法依賴的package包/類
@Override
public void attachToPropertySubGroup(AbstractELTContainerWidget container) {
	ELTDefaultSubgroupComposite defaultSubgroupComposite = new ELTDefaultSubgroupComposite(
			container.getContainerControl());
	buttonText = radioButtonConfig.getWidgetDisplayNames();
	buttons = new Button[buttonText.length];
	defaultSubgroupComposite.createContainerWidget();
	defaultSubgroupComposite.numberOfBasicWidgets(buttonText.length + 1);

	AbstractELTWidget defaultLabel = new ELTDefaultLable(radioButtonConfig.getPropertyName());
	defaultSubgroupComposite.attachWidget(defaultLabel);

	setPropertyHelpWidget((Control) defaultLabel.getSWTWidgetControl());
	
	SelectionListener selectionListener = new SelectionAdapter() {
		@Override
		public void widgetSelected(SelectionEvent event) {
			Button button = ((Button) event.widget);

			matchValue.setMatchValue(button.getText());
			matchValue.setRadioButtonSelected(true);
			propertyDialogButtonBar.enableApplyButton(true);
		}
	};

	
	for (int i = 0; i < buttonText.length; i++) {
		ELTRadioButton eltRadioButton = new ELTRadioButton(buttonText[i]);
		defaultSubgroupComposite.attachWidget(eltRadioButton);
		buttons[i] = ((Button) eltRadioButton.getSWTWidgetControl());
		((Button) eltRadioButton.getSWTWidgetControl()).addSelectionListener(selectionListener);
	}
	buttons[0].setSelection(true);
	
	if(!radioButtonConfig.getRadioButtonListners().isEmpty()){
		Stream<Button> stream = Arrays.stream(buttons);
		stream.forEach(button -> {
		Listners radioListners = radioButtonConfig.getRadioButtonListners().get(0);
		IELTListener listener = radioListners.getListener();
		Listener listnr = listener.getListener(propertyDialogButtonBar, null, button);
		button.addListener(SWT.Selection, listnr);});
	}
	 populateWidget();
}
 
開發者ID:capitalone,項目名稱:Hydrograph,代碼行數:45,代碼來源:RadioButtonsWidget.java

示例13: stream

import java.util.Arrays; //導入方法依賴的package包/類
/** Returns a stream over the values in this array, in order. */
public IntStream stream() {
  return Arrays.stream(array, start, end);
}
 
開發者ID:zugzug90,項目名稱:guava-mock,代碼行數:5,代碼來源:ImmutableIntArray.java

示例14: packCriteriaTable

import java.util.Arrays; //導入方法依賴的package包/類
private void packCriteriaTable() {
	Stream<TableColumn> stream = Arrays.stream(tableCriteria.getColumns());
	stream.forEach(tc -> tc.pack());
}
 
開發者ID:gw4e,項目名稱:gw4e.project,代碼行數:5,代碼來源:ModelSearchPage.java

示例15: of

import java.util.Arrays; //導入方法依賴的package包/類
/**
 * Returns a sequential ordered stream whose elements are the specified values.
 *
 * @param values the elements of the new stream
 * @return the new stream
 */
public static IntStream of(int... values) {
    return Arrays.stream(values);
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:10,代碼來源:IntStream.java


注:本文中的java.util.Arrays.stream方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。