276 {
277 constexpr ERRCODE DONT_EXCHANGE_DELETED("Can't exchange deleted elements of lists");
278
279 ELIST_LINK *old_current;
280
281#ifndef NDEBUG
282 if (!list)
284 if (!other_it)
286 if (!(other_it->list))
288#endif
289
290
291
292
293 if ((list->
empty()) || (other_it->list->empty()) || (current == other_it->current)) {
294 return;
295 }
296
297
298
299 if (!current || !other_it->current) {
300 DONT_EXCHANGE_DELETED.error(
"ELIST_ITERATOR.exchange",
ABORT);
301 }
302
303
304
305
306
307
308 if ((next == other_it->current) || (other_it->next == current)) {
309
310 if ((next == other_it->current) && (other_it->next == current)) {
311 prev = next = current;
312 other_it->prev = other_it->next = other_it->current;
313 } else {
314
315
316 if (other_it->next == current) {
317 other_it->prev->next = current;
318 other_it->current->next = next;
319 current->next = other_it->current;
320 other_it->next = other_it->current;
321 prev = current;
322 } else {
323 prev->next = other_it->current;
324 current->next = other_it->next;
325 other_it->current->next = current;
326 next = current;
327 other_it->prev = other_it->current;
328 }
329 }
330 } else {
331 prev->next = other_it->current;
332 current->next = other_it->next;
333 other_it->prev->next = current;
334 other_it->current->next = next;
335 }
336
337
338
339
340 if (list->last == current) {
341 list->last = other_it->current;
342 }
343 if (other_it->list->last == other_it->current) {
344 other_it->list->last = current;
345 }
346
347 if (current == cycle_pt) {
348 cycle_pt = other_it->cycle_pt;
349 }
350 if (other_it->current == other_it->cycle_pt) {
351 other_it->cycle_pt = cycle_pt;
352 }
353
354
355
356 old_current = current;
357 current = other_it->current;
358 other_it->current = old_current;
359}