我是靠谱客的博主 鲜艳野狼,这篇文章主要介绍java hashmap倒序_如何在Java中以相反的顺序迭代hashmap,现在分享给大家,希望可以做个参考。

我尝试了一个小时,但没有找到任何最佳方法来实现反向的哈希图迭代,这就是我拥有的哈希图。

Map> map = new HashMap>();

for(Integer key : map.keySet()) {

List value = map.get(key);

List> security = new LinkedList>();

for(int ixy = 0; ixy < value.size()-1; ixy++){

security.add(createItem(value.get(ixy), value.get(ixy+1)));

}

adapter.addSection(Integer.toString(key), new SimpleAdapter(getApplicationContext(), security, R.layout.list_complex, new String[] { ITEM_TITLE, ITEM_CAPTION }, new int[] { R.id.list_complex_title, R.id.list_complex_caption }));

}

我也看过TreeMap的例子,

Map> sortedMap = new TreeMap>(map);

但是treemap也按升序给出,我想要的是降序。

最后

以上就是鲜艳野狼最近收集整理的关于java hashmap倒序_如何在Java中以相反的顺序迭代hashmap的全部内容,更多相关java内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(44)

评论列表共有 0 条评论

立即
投稿
返回
顶部