public static void CopyTo <T>(this IRawContainer <T> source, int src_start_index, IRawContainer <T> dest, int dst_start_index, int count) where T : unmanaged { if (source.size() - src_start_index < count || dest.size() - dst_start_index < count) { throw new InvalidOperationException("can't copy to dest. reason: 'overflow'"); } else if (count <= 0) { return; } else if (source == dest) { Internal_CopySelf(source, src_start_index, dst_start_index, count); return; } RawIterator <T> src_iter = source.begin() + src_start_index; RawIterator <T> dst_iter = dest.begin() + dst_start_index; for (; --count >= 0; dst_iter++, src_iter++) { *dst_iter.Value = *src_iter.Value; } }
public static T[] ToArray <T>(this IRawContainer <T> source) where T : unmanaged { int sz = source.size(); T[] result = new T[sz]; for (RawReverseIterator <T> r_iter = source.rbegin(); --sz >= 0; r_iter++) { result[sz] = *r_iter.Value; } return(result); }
public static void CopyTo <T>(this IRawContainer <T> source, IRawContainer <T> dest) where T : unmanaged => CopyTo(source, 0, dest, 0, source.size());