292 {
293 constexpr ERRCODE DONT_EXCHANGE_DELETED(
294 "Can't exchange deleted elements of lists");
295
297
298 #ifndef NDEBUG
299 if (!list)
301 if (!other_it)
303 if (!(other_it->list))
305 #endif
306
307
308
309
310 if ((list->
empty ()) ||
311 (other_it->list->
empty ()) || (current == other_it->current))
312 return;
313
314
315
316 if (!current || !other_it->current)
317 DONT_EXCHANGE_DELETED.error (
"ELIST_ITERATOR.exchange",
ABORT,
nullptr);
318
319
320
321
322
323
324 if ((next == other_it->current) ||
325 (other_it->next == current)) {
326
327 if ((next == other_it->current) &&
328 (other_it->next == current)) {
329 prev = next = current;
330 other_it->prev = other_it->next = other_it->current;
331 }
332 else {
333
334
335 if (other_it->next == current) {
336 other_it->prev->next = current;
337 other_it->current->next = next;
338 current->next = other_it->current;
339 other_it->next = other_it->current;
340 prev = current;
341 }
342 else {
343 prev->next = other_it->current;
344 current->next = other_it->next;
345 other_it->current->next = current;
346 next = current;
347 other_it->prev = other_it->current;
348 }
349 }
350 }
351 else {
352 prev->next = other_it->current;
353 current->next = other_it->next;
354 other_it->prev->next = current;
355 other_it->current->next = next;
356 }
357
358
359
360
361 if (list->last == current)
362 list->last = other_it->current;
363 if (other_it->list->last == other_it->current)
364 other_it->list->last = current;
365
366 if (current == cycle_pt)
367 cycle_pt = other_it->cycle_pt;
368 if (other_it->current == other_it->cycle_pt)
369 other_it->cycle_pt = cycle_pt;
370
371
372
373 old_current = current;
374 current = other_it->current;
375 other_it->current = old_current;
376}