多个数组列表连接到一个单一的数组列表 [英] Connect multiple arraylist to one single array list

查看:108
本文介绍了多个数组列表连接到一个单一的数组列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个数组列表数组列表,我想让它的独立观点将它过滤某些事情,一些地方保存起来以备以后使用。我刨使用数组列表数组列表,并想知道如果数组列表必须连接在一起的方式,其中一个变化反映了另一个?有什么想法吗 ?它就像一个Excel工作表,我想筛选出特定号码,我将显示在同一张纸上的另一种观点并没有真正改变原有的表。请帮忙。

I have an array list of a array list and I want to make a separate view of it that will filter certain things from it and store it somewhere for later usage. I am planing on using an array list of array list and was wondering if array list has a way to be connected together where the change in one reflects another ? Any thoughts ? Its like an excel sheet and I would like to filter out certain numbers and I will display another view of the same sheet without really changing the original sheet. please help.

推荐答案

根据您解释这个问题,你可以保持排序列表..然后做一个子集(探索通航集,看看它是如何实现的)。 。包你子集到一个不可修改的列表或当您正在暴露它一个新的列表。
您还可以,如果你会遇到重复的排序/导航地图..所以地图中的值可以是副本的数目。现在,当你查询本地图的头部或尾部返回的视图中,可以使用重复的数量来达到所需的列表。

based on your explanation to the question, you can keep a sorted list.. and then do a sub set (explore navigable set and see how its implemented).. wrap you sub-set into a non-modifiable list or a new list whenever your are exposing it. You can also a sorted/ navigable map if you expect to encounter duplicates.. so the value in the map can be number of duplicates. Now when you query this map for its head or tail to return the view, you can use the number of duplicates to achieve the desired list.

    NavigableSet<Integer> orderedSet = new ConcurrentSkipListSet<Integer>(Arrays.asList(new Integer[] {11, 20, 32, 14,
            5})); // or tree set if thread safety is not a concern.
    orderedSet.headSet(20); // will give you integers upto 20 i.e. [5, 11, 14]

这篇关于多个数组列表连接到一个单一的数组列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆