SHOW:
|
|
- or go back to the newest paste.
1 | - | Item* listGet (ArrayList *list, Int key) { |
1 | + | Item* listAt (ArrayList *list, int pos) { |
2 | Node *no = list->firstNode; | |
3 | - | Item *res; |
3 | + | int count = 1; |
4 | while (no) { | |
5 | - | res = buscaBinaria(no, 0, no->last); |
5 | + | if (count + last >= pos) |
6 | - | if (res != NULL) |
6 | + | return no->items[pos-count]; |
7 | - | return res; |
7 | + | else |
8 | - | no = no->next; |
8 | + | count += last + 1; |
9 | } | |
10 | return NULL; | |
11 | } |