60 // same compare function, lists are compatible |
60 // same compare function, lists are compatible |
61 return list->cl->compare(list, other); |
61 return list->cl->compare(list, other); |
62 } else { |
62 } else { |
63 // different compare functions, use iterator |
63 // different compare functions, use iterator |
64 if (list->size == other->size) { |
64 if (list->size == other->size) { |
65 // TODO: we would need a const iterator |
|
66 CxIterator left = cxListBegin(list); |
65 CxIterator left = cxListBegin(list); |
67 CxIterator right = cxListBegin(other); |
66 CxIterator right = cxListBegin(other); |
68 for (size_t i = 0; i < list->size; i++) { |
67 for (size_t i = 0; i < list->size; i++) { |
69 void *leftValue = cxIteratorCurrent(&left); |
68 void *leftValue = cxIteratorCurrent(left); |
70 void *rightValue = cxIteratorCurrent(&right); |
69 void *rightValue = cxIteratorCurrent(right); |
71 int d = list->cmpfunc(leftValue, rightValue); |
70 int d = list->cmpfunc(leftValue, rightValue); |
72 if (d != 0) { |
71 if (d != 0) { |
73 return d; |
72 return d; |
74 } |
73 } |
75 cxIteratorNext(&left); |
74 cxIteratorNext(left); |
76 cxIteratorNext(&right); |
75 cxIteratorNext(right); |
77 } |
76 } |
78 return 0; |
77 return 0; |
79 } else { |
78 } else { |
80 return list->size < other->size ? -1 : 1; |
79 return list->size < other->size ? -1 : 1; |
81 } |
80 } |