/// <summary> /// Swaps the contents of 'target' with 'source' if the buffers are allocated (1), /// copies the contents of 'source' to 'target' otherwise (2). /// Groups should be of same TotalLength in case 2. /// </summary> public static bool SwapOrCopyContent(MemoryGroup <T> target, MemoryGroup <T> source) { if (source is Owned ownedSrc && ownedSrc.Swappable && target is Owned ownedTarget && ownedTarget.Swappable) { Owned.SwapContents(ownedTarget, ownedSrc); return(true); }