ENH: support UList[labelRange] and SubList construction with labelRange
This uses a concept similar to what std::valarray and std::slice do. A labelRange provides a convenient container for holding start/size and lends itself to addressing 'sliced' views of lists. For safety, the operations and constructors restricts the given input range to a valid addressible region of the underlying list, while the labelRange itself precludes negative sizes. The SubList version is useful for patches or other things that have a SubList as its parameter. Otherwise the UList [] operator will be the more natural solution. The slices can be done with a labelRange, or a {start,size} pair. Examples, labelList list1 = identity(20); list1[labelRange(18,10)] = -1; list1[{-20,25}] = -2; list1[{1000,5}] = -3; const labelList list2 = identity(20); list2[{5,10}] = -3; // ERROR: cannot assign to const!
Showing
- applications/test/List/Test-List.C 60 additions, 2 deletionsapplications/test/List/Test-List.C
- src/OpenFOAM/containers/Lists/SubList/SubList.H 22 additions, 5 deletionssrc/OpenFOAM/containers/Lists/SubList/SubList.H
- src/OpenFOAM/containers/Lists/SubList/SubListI.H 27 additions, 6 deletionssrc/OpenFOAM/containers/Lists/SubList/SubListI.H
- src/OpenFOAM/containers/Lists/UList/UList.C 82 additions, 1 deletionsrc/OpenFOAM/containers/Lists/UList/UList.C
- src/OpenFOAM/containers/Lists/UList/UList.H 36 additions, 1 deletionsrc/OpenFOAM/containers/Lists/UList/UList.H
- src/OpenFOAM/containers/Lists/UList/UListI.H 2 additions, 5 deletionssrc/OpenFOAM/containers/Lists/UList/UListI.H
Please register or sign in to comment