c# - I want to return a sublist of object and Total size of the Original List -


i want return sublist of object , total size of original list.

in case can use map .

example :-

map<integer,string> sample(){ list<string> list = new arraylist<string>(0);  for(i=0;i<50;i++) list.add(i+"");  list<string> sublist = list.sublist(0,10); integer totalsize = list.size(); map<integer,string> map = new hashmap<integer,list>(0); map.put(totalsize,sublist); return map; } 

otherwise can return 1 pojo object fro returning these information calling function.

i need performance wise guidance on .

you need map store sublist , size of original list 2 different keys, here code in java meet req...


map<integer, string> sample() {     map map = new hashmap();     list<string> list = new arraylist<string>(0);      ( int = 0; < 50; i++)         list.add(i + "");      list<string> sublist = list.sublist(0, 10);     integer totalsize = list.size();      map.put("sublist", sublist);     map.put("original_list_length", totalsize);      return map; } 


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -