本文整理匯總了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);
}