我在java中使用lambda函数进行Radix排序。
我想解决的问题是:
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<div class="container">
<h1>Our Peoples</h1>
<div class="peoples">
<div class="people">
<h1>John</h1>
<img src="http://www.math.uni-frankfurt.de/~person/_4170854.jpg" alt="p1">
<p>Months on ye at by esteem desire warmth former. Sure that that way gave any fond now. His boy middleton sir nor engrossed affection excellent. Dissimilar compliment cultivated preference eat sufficient may. Well next door soon we mr he four. Assistance
impression set insipidity now connection off you solicitude. Under as seems we me stuff those style at. Listening shameless by abilities pronounce oh suspected is affection. Next it draw in draw much bred. </p>
<div class="link">
<ul>
<li><a href="https://facebook.com"><i class="fa fa-facebook"></i></a></li>
<li><a href="https://twitter.com"><i class="fa fa-twitter"></i></a></li>
<li><a href="https://bd.linkedin.com/"><i class="fa fa-linkedin"></i></a></li>
<li><a href="https://www.instagram.com/?hl=en"><i class="fa fa-instagram"></i></a></li>
</ul>
</div>
</div>
<div class="people">
<h1>Jonathan</h1>
<img src="https://www.jamsadr.com/images/neutrals/person-donald-900x1080.jpg" alt="p2">
<p>His followed carriage proposal entrance directly had elegance. Greater for cottage gay parties natural. Remaining he furniture on he discourse suspected perpetual. Power dried her taken place day ought the. Four and our ham west miss. Education
shameless who middleton agreement how. We in found world chief is at means weeks smile.</p>
<div class="link">
<ul>
<li><a href="https://facebook.com"><i class="fa fa-facebook"></i></a></li>
<li><a href="https://twitter.com"><i class="fa fa-twitter"></i></a></li>
<li><a href="https://bd.linkedin.com/"><i class="fa fa-linkedin"></i></a></li>
<li><a href="https://www.instagram.com/?hl=en"><i class="fa fa-instagram"></i></a></li>
</ul>
</div>
</div>
<div class="people">
<h1>Maria</h1>
<img src="https://engineering.unl.edu/images/staff/Kayla_Person-small.jpg" alt="p3">
<p>Gay one the what walk then she. Demesne mention promise you justice arrived way. Or increasing to in especially inquietude companions acceptance admiration. Outweigh it families distance wandered ye an. Mr unsatiable at literature connection favourable.
We neglected mr perfectly continual dependent. </p>
<div class="link">
<ul>
<li><a href="https://facebook.com"><i class="fa fa-facebook"></i></a></li>
<li><a href="https://twitter.com"><i class="fa fa-twitter"></i></a></li>
<li><a href="https://bd.linkedin.com/"><i class="fa fa-linkedin"></i></a></li>
<li><a href="https://www.instagram.com/?hl=en"><i class="fa fa-instagram"></i></a></li>
</ul>
</div>
</div>
</div>
</div>
</body>
</html>
但是这段代码与java中的lambda演算不兼容,因为java需要非最终值。 我尝试过这样的事情:
int[] input = ...
...
for(int p : position) {
//process using input values
int[] b = Arrays.stream(input).parallel().map(x -> x >> p & 1 ).toArray();
...
//process which change the place of element i to the place of d[i]
int[] output = new int[input.length];
IntStream.range(0, input.length).forEach(i -> output[d[i]] = input[i]);
input = output
}
但java告诉我输出不是初始化或不存在。
如何绕过这个问题? 我应该使用FrokJoinPool编写自己的功能吗? 在这种情况下,我想到创建n(输入的大小)函数,它将input [i]的元素放置在d [i]的位置的新数组中。然后使用ForkJoinPool.invokeALL()启动它们。
提前致谢!
我已解决了该行的问题: int [] tmp = input
这是我的所有代码,我正在创建大量的数组,你认为它是一个做基数排序的好方法还是创建了太多的数组?
for(int p : position) {
if(p==0){
int[] tmp = input ;
}
else {
int[] tmp = output;
}
int[] b = ...
}