![]() |
ObjexxFCL 3.0 |
|||||||
Index RangesAs in Fortran, each dimension of an FArray can be given an arbitrary index range. An index range is specified by its lower and upper indices. The ObjexxFCL IndexRange class hierarchy provides this index range capability. IndexRange is an abstract base class of StaticIndexRange and DynamicIndexRange. IndexRange is the abstract base class and functions that can work with StaticIndexRange and DynamicIndexRange objects uniformly can be written to handle them as abstract IndexRange objects. StaticIndexRange ranges are used in argument FArrays and they are not automatically updated by changes to Dimension objects in their assigned values. The SRange shorthand (typedef) name for StaticIndexRange is used below. DynamicIndexRange ranges are used in real and proxy FArrays and they are automatically updated by changes to Dimension objects in their assigned values. The DRange shorthand (typedef) name for DynamicIndexRange is used below. ConstructionDefault constructors create zero-sized ranges [1,0]. Copy constructors are available for all IndexRange types. Upper index constructors taking a single argument create ranges with a lower index of 1. The upper index argument can be any value convertible to int, a Dimension or Dimension expression, or ObjexxFCL::star to indicate an unbounded upper index (for the last dimension of assumed-size argument/proxy arrays). Index range constructors taking lower and upper index arguments create ranges with the specified range. The lower and upper index arguments can be any value convertible to int or a Dimension or Dimension expression. The upper index argument can also be ObjexxFCL::star to indicate an unbounded upper index (for the last dimension of assumed-size argument/proxy arrays). Here are some sample IndexRange constructors:
AssignmentIndexRanges assignment operators and functions parallel the constructors. Assignments with the = operator match the single argument constructors and the assign member functions parallel the upper index and index range constructors. Single argument l and u member functions can be used to assign just the lower or upper index, respectively. FunctionsThe lower and upper indices of an IndexRange can be accessed with the l and u member functions and the size with the size member function:
A number of predicate (boolean) functions are available for IndexRanges, including initialized, bounded, unbounded, and legal. You can also ask an IndexRange whether it contains an index or another range or whether it intersects another range. The contain and intersect modifying member functions will modify an IndexRange to contain a specified index or range or to intersect a specified range, respectively. The clear member function will clear an IndexRange back to a default-constructed state. You can compare two index ranges with the operators { ==, !=, >, >=, <, <= }. Notes on IndexRanges
|
||||||||
| | | | | | | | ||||||||
| Copyright © 2000-2009 Objexx Engineering, Inc. All Rights Reserved. | ||||||||