本文整理汇总了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);
}
示例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;
}
示例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);
}
示例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();
}
}
示例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(" "));
}
}
示例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);
}
示例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();
}
}
示例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);
}
示例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();
}
}
示例10: constructor
import java.util.Arrays; //导入方法依赖的package包/类
public static Stream<Constructor> constructor(Class<?> cls) {
return Arrays.stream(cls.getDeclaredConstructors());
}
示例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;
}
示例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();
}
示例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);
}
示例14: packCriteriaTable
import java.util.Arrays; //导入方法依赖的package包/类
private void packCriteriaTable() {
Stream<TableColumn> stream = Arrays.stream(tableCriteria.getColumns());
stream.forEach(tc -> tc.pack());
}
示例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);
}