416 */ |
416 */ |
417 template<typename ...Args> |
417 template<typename ...Args> |
418 ByteArray::ByteArray(Args&& ...args) : |
418 ByteArray::ByteArray(Args&& ...args) : |
419 Vector<unsigned char>(args...) {} |
419 Vector<unsigned char>(args...) {} |
420 |
420 |
|
421 template<typename T> |
|
422 T splice(const T& container, int start, int end, int step = 1) |
|
423 { |
|
424 start = clamp(start, 0, static_cast<int>(container.size())); |
|
425 end = clamp(end, 0, static_cast<int>(container.size())); |
|
426 T result; |
|
427 result.reserve((end - start) / step); |
|
428 for (int i = start; i < end; i += step) |
|
429 { |
|
430 result.push_back(container[i]); |
|
431 } |
|
432 return result; |
|
433 } |
|
434 |
|
435 template<typename T> |
|
436 T splice(const T& container, Range<int>& range) |
|
437 { |
|
438 return splice(container, range.min(), range.max(), range.step()); |
|
439 } |
|
440 |
421 END_ZFC_NAMESPACE |
441 END_ZFC_NAMESPACE |