当前位置: 首页>>代码示例>>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;未经允许,请勿转载。