• Mark OLESEN's avatar
    ENH: support UList[labelRange] and SubList construction with labelRange · 805b76d4
    Mark OLESEN authored
    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!
    805b76d4