java - 循环嵌套列表 RxJava2
问题描述
我有一个对象 A 的列表,并且在每个 AI 中都有一个对象 B 的列表。
这是我想做的:
在List<A>
使用 RxJava 循环时,我希望能够循环内部列表并List<B>
在最后对 and 进行一些过滤,我想将过滤List<B>
后的List<A>
.
在不破坏链条的情况下可以进行此操作吗?
像这个例子:
class A {
int mAId;
List<B> mBList;
}
class B{
int mId;
}
public void loop(List<A> list){
Observable.fromIterable(list)
.flatMapIterable(objs-> objs.mBList)
.filter("filtering each b")
.toList()
.map("add back the list of b to the right a")
.subscribe()
}
解决方案
我的意见:
public void loop(List<A> list){
List<FromObject> innerList;
list.forEach(e->{
innerList=e.getInnerList();
innerList.forEach(in->{
<apply your filter here>
<for example>
if(in.getNumber()>0)
innerList.remove(in);
}
}
}
希望它会有所帮助
推荐阅读
- java - 如何在android studio中正确安装jdbc驱动?
- android - 从通知启动时在现有后台堆栈顶部添加活动
- java - 在不紧接在数字之前的特定单词之后搜索数字
- laravel - Laravel 路由不适用于子文件夹
- r - Rtweet 包中的 Post_list 函数
- android - Android - 应用内购买测试 - 我需要 2 部手机吗?
- android - 将 Qt 与 MAPI 绑定
- c# - 无法将机器人链接到机器人框架模拟器
- cucumber - 如何在另一个功能文件之后运行一个功能文件?
- javascript - 我想将我的数据添加到 Angular 中的 ui