STK_Inx.h

Go to the documentation of this file.
00001 /*--------------------------------------------------------------------*/
00002 /*     Copyright (C) 2004-2009  Serge Iovleff
00003 
00004     This program is free software; you can redistribute it and/or modify
00005     it under the terms of the GNU Lesser General Public License as
00006     published by the Free Software Foundation; either version 2 of the
00007     License, or (at your option) any later version.
00008 
00009     This program is distributed in the hope that it will be useful,
00010     but WITHOUT ANY WARRANTY; without even the implied warranty of
00011     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012     GNU Lesser General Public License for more details.
00013 
00014     You should have received a copy of the GNU Lesser General Public
00015     License along with this program; if not, write to the
00016     Free Software Foundation, Inc.,
00017     59 Temple Place,
00018     Suite 330,
00019     Boston, MA 02111-1307
00020     USA
00021 
00022     Contact : Serge.Iovleff@stkpp.org
00023 */
00024 /*--------------------------------------------------------------------*/
00025 /* $Id$
00026  *
00027  * Project:  Base
00028  * Purpose:  Define the Inx class.
00029  * Author:   Serge Iovleff, serge.iovleff@stkpp.org
00030  *
00031  * $Log$
00032  * Revision 1.4  2009/09/14 13:33:38  siovleff
00033  * Refactoring Contant strings
00034  *
00035  **/
00036 /*--------------------------------------------------------------------*/
00042 #ifndef STK_INX_H
00043 #define STK_INX_H
00044 
00045 #include "STK_Integer.h"
00046 #include "STK_Stream.h"
00047 
00048 namespace STK
00049 {
00050 /*--------------------------------------------------------------------*/
00068 class Inx
00069 {
00070   private:
00071     Integer first_;    
00072     Integer last_;     
00073     Integer size_;     
00074 
00075   public:
00076     /*----------------------------------------------------------------*/
00077     /* Ctors.                                                         */
00079     Inx(const Integer& last =0);
00080 
00085     Inx(const Integer& first, const Integer& last);
00086 
00090     Inx(const Inx &I);
00091 
00093      ~Inx();
00094 
00095     /*----------------------------------------------------------------*/
00096     /* Accessors.                                                     */
00098     inline Integer first()  const { return first_;};
00099 
00101     inline Integer last()    const { return last_;};
00102 
00104     inline Integer size()   const { return size_;};
00105 
00107     inline bool    empty() const { return size_<=0;};
00108 
00110     inline Integer begin()  const { return first_;};
00111 
00113     inline Integer end()    const { return last_+1;};
00114 
00118     inline bool    isIncludeIn(const Inx &I) const
00119     { return ((first_>= I.first_)&&(last_<=I.last_));}
00120 
00124     inline bool    isContaining(const Inx &I) const
00125     { return ((first_<= I.first_)&&(last_>=I.last_));}
00126 
00130     inline bool    isContaining(const Integer &i) const
00131     { return ((first_<=i)&&(last_>=i));}
00132 
00136     inline bool operator==(const Inx &I) const
00137     { return ((first_ == I.first()) && (last_ == I.last()));}
00138 
00142     inline bool operator!=(const Inx &I) const
00143     { return ((first_ != I.first()) || (last_ != I.last()));}
00144 
00145     /*----------------------------------------------------------------*/
00146     /* Modification Methods.                                          */
00148     Inx& set(const Integer& first =1, const Integer& last =0);
00150     Inx& shift(const Integer& first =1);
00152     Inx& inc(const Integer &inc =1);
00154     Inx& incFirst(const Integer &inc =1);
00156     Inx& incLast(const Integer &inc =1);
00158     Inx& dec(const Integer &dec =1);
00160     Inx& decFirst(const Integer &dec =1);
00162     Inx& decLast(const Integer &dec =1);
00163 
00164     /*----------------------------------------------------------------*/
00165     /* Modification Methods.                                          */
00167     Inx& sup(const Inx &I);
00168 
00170     Inx& inf(const Inx &I);
00171 
00173     static Inx sup(const Inx& I, const Inx& J);
00174 
00176     static Inx inf(const Inx& I, const Inx& J);
00177 
00178     /*----------------------------------------------------------------*/
00179     /* Operators.                                                     */
00180     // The operator = have not been defined, default = is Ok
00182     Inx& operator+=(const Integer &inc);
00184     Inx& operator-=(const Integer &dec);
00186     Inx operator+(const Integer &inc) const;
00188     Inx operator-(const Integer &dec) const;
00190     friend ostream& operator<< (ostream& s, const Inx& I);
00191 };
00192 /* End of the class STK::Inx.                                         */
00193 /*--------------------------------------------------------------------*/
00194 
00195 } // Namespace STK
00196 
00197 #endif
00198 // STK_INX_H
Generated on Sat Sep 18 17:26:51 2010 for STK++ by  doxygen 1.6.3