当前位置:网站首页>À propos de l'utilisation intelligente du flux et de la carte
À propos de l'utilisation intelligente du flux et de la carte
2022-07-06 17:04:00 【C'est une bombe intelligente.】
Voilà le titre.
//HypothèsesdbDeux de ces tableaux Données disponibles100w Ce qui finit par revenir, c'estProviceLe tableauListEnsemble SistatusPourfasle Ne retourne pas Comment fairejavaEt les couches??
public class Mydemo {
static ArrayList<Province> provinces = new ArrayList<>();
static ArrayList<ProvinceStatus> provinceStatusList = new ArrayList<>();
static {
for (int i = 0; i < 10000; i++) {
Province province = new Province();
ProvinceStatus provinceStatus = new ProvinceStatus();
province.setName(UUID.randomUUID().toString());
province.setProvinceId(i);
provinceStatus.setProvinceId(i);
provinceStatus.setStatus(new Random().nextBoolean());
//Ajouter
provinces.add(province);
provinceStatusList.add(provinceStatus);
}
System.out.println(" La taille de la liste affichée est :" + provinceStatusList.stream().filter(ProvinceStatus::getStatus).count());
}
public static void main(String[] args) {
ArrayList<Province> resList = new ArrayList<>();
System.out.println(" Nombre final affiché :" + resList.size());
}
}
@Data
class Province {
private Integer provinceId;
private String name;
}
@Data
class ProvinceStatus {
private Integer provinceId;
private Boolean status;
}
La réponse est la suivante:, Si vous avez une meilleure idée, laissez un message. !
public static void main(String[] args) {
//DoubleforCycle? - Non. AvechashC'est un bon moyen
long start1 = System.currentTimeMillis();
System.out.println();
Map<Integer, Boolean> map = provinceStatusList.stream()
.collect(Collectors.toMap(ProvinceStatus::getProvinceId, ProvinceStatus::getStatus));
ArrayList<Province> resList = new ArrayList<>();
for (Province province : Mydemo.provinces) {
if (map.get(province.getProvinceId())) {
// Montre - moi ça.
resList.add(province);
}
}
long start2 = System.currentTimeMillis();
System.out.println("Temps d'utilisation:" + (start2 - start1));
System.out.println(" Nombre final affiché :" + resList.size());
}
}
Mesure réelle lorsque la quantité de données est importante , Les flux parallèles sont plus lents , Parce qu'il n'y a pas eu de calcul. , Après tout, les flux parallèles conviennent CPUTâches intensives, C'est - à - dire lorsqu'il y a beaucoup de calculs .
边栏推荐
- Error occurred during initialization of VM Could not reserve enough space for object heap
- GCC error: terminate called after throwing an instance of 'std:: regex_ error‘ what(): regex
- Shell_ 00_ First meeting shell
- Log4j2 major vulnerabilities and Solutions
- 字节跳动海外技术团队再夺冠:高清视频编码已获17项第一
- ~78 radial gradient
- Koa Middleware
- js垃圾回收机制和内存泄漏
- ByteDance open source Gan model compression framework, saving up to 97.8% of computing power - iccv 2021
- 数据传送指令
猜你喜欢

Activiti目录(五)驳回、重新发起、取消流程

Fdog series (V): use QT to imitate QQ to realize login interface to main interface, function chapter.

Some instructions on whether to call destructor when QT window closes and application stops

~76 sprite map

Activiti directory (V) reject, restart and cancel process

Erlang installation

~84 form supplement

Shell_ 03_ environment variable

~74 JD top navigation bar exercise

100张图训练1小时,照片风格随意变,文末有Demo试玩|SIGGRAPH 2021
随机推荐
Login to verify the simple use of KOA passport Middleware
8086 分段技术
Shell_ 03_ environment variable
DOS function call
吴军三部曲见识(七) 商业的本质
Activit fragmented deadly pit
Activit零零碎碎要人命的坑
唯有学C不负众望 TOP3 Demo练习
Thank you for your invitation. I'm in the work area. I just handed in the code. I'm an intern in the next ByteDance
~86m rabbit practice
8086 memory
Many papers on ByteDance have been selected into CVPR 2021, and the selected dry goods are here
README. txt
Solr standalone installation
Full record of ByteDance technology newcomer training: a guide to the new growth of school recruitment
Install docker under windows10 (through Oracle VM VirtualBox)
Saw local status change event StatusChangeEvent [timestamp=1644048792587, current=DOWN, previous=UP]
汇编语言段定义
~70 row high
IDEA断点调试技巧,多张动图包教包会。