开发者

Get data from a Collection of maps with 2 int as parameters

开发者 https://www.devze.com 2023-03-11 08:37 出处:网络
I have a variable like: Collection<Map<String, String>> allFieldValues; In this variable I have all the data of a sqlite Table, each map of the collection represents a row of the table.

I have a variable like:

Collection<Map<String, String>> allFieldValues;

In this variable I have all the data of a sqlite Table, each map of the collection represents a row of the table.

Now I have to take the data of a specific cell, my parameters are 2 ints (row number, column number), so I am trying something like this:

Iterator<Map<String, String>> iter = allFieldValues.iterator();
for (int i = 0; i == givenRowAsParameter; i++)
{
    iter.next();
}

And thats it, the iter that I get out of the loop its supossed to be the row that I want, but I can't take anoth开发者_开发百科er Iterator from that Iterator to search for the column, neither I can't get a specific object of the iterator with just an int as a parameter. So Im stuck :(

Any suggestions? thanks a lot!


Following your methodology for defining row index, you can use:

Iterator<Map<String, String>> iter = allFieldValues.iterator();
Map<String, String> row;
for (int i = 0; i <= rowIndex; i++) {
    row = iter.next();
}

String col;
Iterator<String> iter2 = row.values().iterator();
for (int i = 0; i <= colIndex; i++) {
    col = iter2.next();
}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号