Skip to content
Snippets Groups Projects
Commit 805b76d4 authored by Mark OLESEN's avatar Mark OLESEN
Browse files

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!
parent 75ef6f4e
Branches
Tags
No related merge requests found
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment