利用Map集合將list集合中資料進行拆分。

2021-10-01 16:39:35 字數 710 閱讀 5498

如下**中orderlist為原生的資料集合體。根據standardid欄位值來進行區分資料。

hashmap集合以 standardid為key,templist 為value;

/**

* @param orderlist:

* @return map>

* @title productionequipmentisrepeat

* @description 校驗list集合standardid是否有重複,並將集合分成2個集合,1==重複資料集合,2==非重複資料

* @author

* @date 2019/12/18 9:15

*/private map> productionisrepeat(listorderlist) else

}//key==1 重複資料集合 key==2 不重複資料集合

map> map = new hashmap<>();

該方法並不是返回乙個儲存資料的集合而是返回此對映所包含的對映關係的set檢視。(通俗來講就是返回乙個set集合)這個方法可以讀取到其所在的hashmap物件的儲存的鍵值對,而我們經常使用entryset方法就是用來進行foreach迴圈的。

for(map.entry> entry : hashmap.entryset())else

}elseelse}}

return map;

}

遍歷List中的Map集合

list 是傳入的錶身資料 listlist new arraylist for int i 0 itfpss tfpss new tfpss beanutils.copyproperties mfpsswithblobs.getparams get i tfpss list.add tfpss l...

Scala中List集合與Map集合的相互轉換

list集合轉換成map集合object demo println tuples 將list轉換成map val map map string,int tuples.tomap println map 結果為 list dog,3 tiger,5 lion,4 cat,3 panther,7 eag...

Map集合與List集合混合使用對比

作為乙個剛開始學程式設計的人來說,下面文字的一些表述肯定會有錯誤,希望前輩們多多批評,或者等以後我自己回過頭來覺得自己當初怎麼這麼菜,那也說明我進步了。嗯,就這樣開始吧!思路一 學校教室的名稱 班級,id和name,分別可以作為map集合裡的鍵和值,也就是分別都有對映關係。這個思路的特點是使用了兩層...