Changeset 2915 in Sophya for trunk/SophyaLib/TArray/utilarr.h


Ignore:
Timestamp:
Feb 22, 2006, 7:17:30 PM (20 years ago)
Author:
ansari
Message:

Amelioration de la classe Range - permettant une valeur symbolique pour specifier le dernier index (last()) - Reza 22/02/2006

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/SophyaLib/TArray/utilarr.h

    r2286 r2915  
    128128class Range {
    129129public:
    130   explicit Range(sa_size_t start=0, sa_size_t end=0, sa_size_t size=1, sa_size_t step=1);
     130  //! Index range start \<= index \<= last()
     131  Range(sa_size_t start);
     132  //! Index range start \<= index \<= end
     133  Range(sa_size_t start, sa_size_t end);
     134  //! Index range start \<= index \<= end with increment step
     135  Range(sa_size_t start, sa_size_t end, sa_size_t step);
     136  //! General Index range specification, using size or start/end and increment
     137  Range(sa_size_t start, sa_size_t end, sa_size_t size, sa_size_t step);
    131138  //! Return the start index
    132139  inline sa_size_t & Start()  {  return start_; }
     
    137144  //! Return the step
    138145  inline sa_size_t & Step()   {  return step_; }
     146  //! return a constant value defining the first element
     147  inline static sa_size_t firstIndex() { return 0; }
     148  //! return a constant value as a placeholder for the last valid index
     149  inline static sa_size_t lastIndex() { return -1; }
     150  //! return a Range object specifing all indices, from first to last
     151  inline static Range all()
     152  { return Range(Range::firstIndex() , Range::lastIndex()); }
     153  //! return a Range object specifing the first index
     154  inline static Range first()
     155  { return Range(Range::firstIndex() , Range::lastIndex(), 1, 1); }
     156  //! return a Range object specifing the last valid index
     157  inline static Range last()
     158  { return Range(Range::lastIndex() , Range::lastIndex(), 1, 1); }
     159
     160  //! For internal TArray module use.
     161  void Update(sa_size_t osz);
     162
    139163protected:
    140164  sa_size_t start_; //!< start index
Note: See TracChangeset for help on using the changeset viewer.