| 192 | |
| 193 | template <typename Combiner> |
| 194 | ByteArray ByteArray::combineWith(Combiner&& combine, ByteArray const& rhs, bool extend) { |
| 195 | ByteArray const* smallerArray = &rhs; |
| 196 | ByteArray const* largerArray = this; |
| 197 | |
| 198 | if (m_size < rhs.size()) |
| 199 | swap(smallerArray, largerArray); |
| 200 | |
| 201 | ByteArray res; |
| 202 | res.resize(smallerArray->size()); |
| 203 | |
| 204 | for (size_t i = 0; i < smallerArray->size(); ++i) |
| 205 | res[i] = combine((*smallerArray)[i], (*largerArray)[i]); |
| 206 | |
| 207 | if (extend) { |
| 208 | res.resize(largerArray->size()); |
| 209 | for (size_t i = smallerArray->size(); i < largerArray->size(); ++i) |
| 210 | res[i] = (*largerArray)[i]; |
| 211 | } |
| 212 | |
| 213 | return res; |
| 214 | } |
| 215 | |
| 216 | inline ByteArray::iterator ByteArray::begin() { |
| 217 | return m_data; |