equal
deleted
inserted
replaced
98 } |
98 } |
99 |
99 |
100 private: |
100 private: |
101 |
101 |
102 void relocate_last(int idx) { |
102 void relocate_last(int idx) { |
103 if (idx + 1 < (int)data.size()) { |
103 if (idx + 1 < int(data.size())) { |
104 data[idx] = data.back(); |
104 data[idx] = data.back(); |
105 if (data[idx].prev != -1) { |
105 if (data[idx].prev != -1) { |
106 data[data[idx].prev].next = idx; |
106 data[data[idx].prev].next = idx; |
107 } else { |
107 } else { |
108 first[data[idx].value] = idx; |
108 first[data[idx].value] = idx; |
125 data[data[idx].next].prev = data[idx].prev; |
125 data[data[idx].next].prev = data[idx].prev; |
126 } |
126 } |
127 } |
127 } |
128 |
128 |
129 void lace(int idx) { |
129 void lace(int idx) { |
130 if ((int)first.size() <= data[idx].value) { |
130 if (int(first.size()) <= data[idx].value) { |
131 first.resize(data[idx].value + 1, -1); |
131 first.resize(data[idx].value + 1, -1); |
132 } |
132 } |
133 data[idx].next = first[data[idx].value]; |
133 data[idx].next = first[data[idx].value]; |
134 if (data[idx].next != -1) { |
134 if (data[idx].next != -1) { |
135 data[data[idx].next].prev = idx; |
135 data[data[idx].next].prev = idx; |
352 } |
352 } |
353 |
353 |
354 private: |
354 private: |
355 |
355 |
356 void relocate_last(int idx) { |
356 void relocate_last(int idx) { |
357 if (idx + 1 != (int)data.size()) { |
357 if (idx + 1 != int(data.size())) { |
358 data[idx] = data.back(); |
358 data[idx] = data.back(); |
359 if (data[idx].prev != -1) { |
359 if (data[idx].prev != -1) { |
360 data[data[idx].prev].next = idx; |
360 data[data[idx].prev].next = idx; |
361 } else { |
361 } else { |
362 first[data[idx].value] = idx; |
362 first[data[idx].value] = idx; |
379 data[data[idx].next].prev = data[idx].prev; |
379 data[data[idx].next].prev = data[idx].prev; |
380 } |
380 } |
381 } |
381 } |
382 |
382 |
383 void lace(int idx) { |
383 void lace(int idx) { |
384 if ((int)first.size() <= data[idx].value) { |
384 if (int(first.size()) <= data[idx].value) { |
385 first.resize(data[idx].value + 1, -1); |
385 first.resize(data[idx].value + 1, -1); |
386 } |
386 } |
387 data[idx].next = first[data[idx].value]; |
387 data[idx].next = first[data[idx].value]; |
388 if (data[idx].next != -1) { |
388 if (data[idx].next != -1) { |
389 data[data[idx].next].prev = idx; |
389 data[data[idx].next].prev = idx; |
605 idx = free; |
605 idx = free; |
606 free = data[idx].next; |
606 free = data[idx].next; |
607 data[idx].item = i; |
607 data[idx].item = i; |
608 } |
608 } |
609 index[i] = idx; |
609 index[i] = idx; |
610 if (p >= (int)first.size()) first.resize(p + 1, -1); |
610 if (p >= int(first.size())) first.resize(p + 1, -1); |
611 data[idx].next = first[p]; |
611 data[idx].next = first[p]; |
612 first[p] = idx; |
612 first[p] = idx; |
613 if (p < minimal) { |
613 if (p < minimal) { |
614 minimal = p; |
614 minimal = p; |
615 } |
615 } |
748 idx = free; |
748 idx = free; |
749 free = data[idx].next; |
749 free = data[idx].next; |
750 data[idx].item = i; |
750 data[idx].item = i; |
751 } |
751 } |
752 index[i] = idx; |
752 index[i] = idx; |
753 if (p >= (int)first.size()) first.resize(p + 1, -1); |
753 if (p >= int(first.size())) first.resize(p + 1, -1); |
754 data[idx].next = first[p]; |
754 data[idx].next = first[p]; |
755 first[p] = idx; |
755 first[p] = idx; |
756 if (p > maximal) { |
756 if (p > maximal) { |
757 maximal = p; |
757 maximal = p; |
758 } |
758 } |