diff -r 9f71f854474a -r 970d58a01e8b sources/list.h --- a/sources/list.h Wed Jul 20 18:31:19 2016 +0300 +++ b/sources/list.h Fri Jul 22 17:59:55 2016 +0300 @@ -58,12 +58,24 @@ Container (const C& other) : m_container (other) {} + Container(std::initializer_list initializerList) : + m_container(initializerList) {} + T& append (const T& value) { m_container.push_back (value); return m_container[m_container.size() - 1]; } + void append(const T* values, size_t numValues) + { + size_t i0 = size(); + resize(size() + numValues); + + for (size_t i : range(numValues)) + (*this)[i0 + i] = values[i]; + } + Iterator begin() { return m_container.begin(); @@ -256,22 +268,29 @@ std::sort (begin(), end()); } - Self splice (int a, int b) const + Self splice(int start, int end, int step = 1) const { - if (a < 0 or b >= size() or b < a) - return Self(); + start = clamp(start, 0, size() - 1); + end = clamp(end, 0, size() - 1); - Self result; + if (end <= start) + { + return Self(); + } + else + { + Self result; - for (int i = a; i < b; ++i) - result << operator[] (i); + for (int i : range(start, end, step)) + result << operator[] (i); - return result; + return result; + } } - Self splice (const Range& a) const + Self splice(Range& range) const { - return splice (a.min(), a.max()); + return splice(range.min(), range.max(), range.step()); } Self& operator<< (const T& value) @@ -358,6 +377,12 @@ Vector (T* data, size_t length) : Super (std::vector (data, data + length)) {} + Vector(std::initializer_list initializerList) : + Super(initializerList) {} + + Vector(const Super& other) : + Super(other) {} + T* data() { return Super::m_container.data(); @@ -374,4 +399,6 @@ } }; +typedef Vector ByteArray; + END_ZFC_NAMESPACE