MCPcopy Create free account
hub / github.com/InteractiveComputerGraphics/PositionBasedDynamics / unflattenList

Function unflattenList

extern/happly/happly.h:243–261  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

241// Unpack flattened list from the convention used in TypedListProperty
242template <typename T>
243std::vector<std::vector<T>> unflattenList(const std::vector<T>& flatList, const std::vector<size_t> flatListStarts) {
244 size_t outerCount = flatListStarts.size() - 1;
245
246 // Put the output here
247 std::vector<std::vector<T>> outLists(outerCount);
248
249 if (outerCount == 0) {
250 return outLists; // quick out for empty
251 }
252
253 // Copy each sublist
254 for (size_t iOuter = 0; iOuter < outerCount; iOuter++) {
255 size_t iFlatStart = flatListStarts[iOuter];
256 size_t iFlatEnd = flatListStarts[iOuter + 1];
257 outLists[iOuter].insert(outLists[iOuter].begin(), flatList.begin() + iFlatStart, flatList.begin() + iFlatEnd);
258 }
259
260 return outLists;
261}
262
263
264}; // namespace

Callers 2

getListPropertyTypeMethod · 0.85

Calls 3

sizeMethod · 0.45
insertMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected