303 {
304 constexpr ERRCODE DONT_EXCHANGE_DELETED(
305 "Can't exchange deleted elements of lists");
306
308
309 #ifndef NDEBUG
310 if (!list)
312 if (!other_it)
314 if (!(other_it->list))
316 #endif
317
318
319
320
321 if ((list->
empty ()) ||
322 (other_it->list->
empty ()) || (current == other_it->current))
323 return;
324
325
326
327 if (!current || !other_it->current)
328 DONT_EXCHANGE_DELETED.error (
"ELIST2_ITERATOR.exchange",
ABORT,
nullptr);
329
330
331
332
333
334
335 if ((next == other_it->current) ||
336 (other_it->next == current)) {
337
338 if ((next == other_it->current) &&
339 (other_it->next == current)) {
340 prev = next = current;
341 other_it->prev = other_it->next = other_it->current;
342 }
343 else {
344
345
346 if (other_it->next == current) {
347 other_it->prev->next = current;
348 other_it->current->next = next;
349 other_it->current->prev = current;
350 current->next = other_it->current;
351 current->prev = other_it->prev;
352 next->prev = other_it->current;
353
354 other_it->next = other_it->current;
355 prev = current;
356 }
357 else {
358 prev->next = other_it->current;
359 current->next = other_it->next;
360 current->prev = other_it->current;
361 other_it->current->next = current;
362 other_it->current->prev = prev;
363 other_it->next->prev = current;
364
365 next = current;
366 other_it->prev = other_it->current;
367 }
368 }
369 }
370 else {
371 prev->next = other_it->current;
372 current->next = other_it->next;
373 current->prev = other_it->prev;
374 next->prev = other_it->current;
375 other_it->prev->next = current;
376 other_it->current->next = next;
377 other_it->current->prev = prev;
378 other_it->next->prev = current;
379 }
380
381
382
383
384 if (list->last == current)
385 list->last = other_it->current;
386 if (other_it->list->last == other_it->current)
387 other_it->list->last = current;
388
389 if (current == cycle_pt)
390 cycle_pt = other_it->cycle_pt;
391 if (other_it->current == other_it->cycle_pt)
392 other_it->cycle_pt = cycle_pt;
393
394
395
396 old_current = current;
397 current = other_it->current;
398 other_it->current = old_current;
399}