Salome HOME
Version ok de MED avec MEDGUI.
[modules/med.git] / src / MEDMEM / MEDMEM_SkyLineArray.hxx
1 # ifndef __MEDSKYLINEARRAY_H__
2 # define __MEDSKYLINEARRAY_H__
3
4 #include "MEDMEM_Exception.hxx"
5
6 #include "MEDMEM_define.hxx"
7
8 using  MED_EN::med_int ;
9
10 class MEDSKYLINEARRAY
11 {
12 private :
13   med_int   _count ;
14   med_int   _length ;
15   med_int * _index ; // array of size _count+1 : _index[0]=1 and 
16                      // _index[_count]=length+1
17   med_int * _value ; // array of size _length
18
19 public :
20   MEDSKYLINEARRAY();
21   ~MEDSKYLINEARRAY();
22   MEDSKYLINEARRAY( const MEDSKYLINEARRAY &myArray );
23   MEDSKYLINEARRAY( const med_int count , const med_int length );
24   
25   void setMEDSKYLINEARRAY( const med_int count, const med_int length, med_int* index , med_int* value ) ;
26
27   inline med_int  getNumberOf()       const;
28   inline med_int  getLength()         const;
29   inline med_int* getIndex()          const; 
30   inline med_int* getValue()          const; 
31   inline med_int  getNumberOfI(int i) const throw (MEDEXCEPTION) ;
32   inline med_int* getI(int i)         const throw (MEDEXCEPTION) ;
33   inline med_int  getIJ(int i, int j) const throw (MEDEXCEPTION) ;
34   
35 } ;
36
37 // ---------------------------------------
38 //              Methodes Inline
39 // ---------------------------------------
40 inline med_int MEDSKYLINEARRAY::getNumberOf() const
41 {
42   return _count ;
43 };
44 inline med_int MEDSKYLINEARRAY::getLength() const
45 {
46   return _length ;
47 };
48 inline med_int* MEDSKYLINEARRAY::getIndex() const 
49
50         return _index ; 
51 } ;
52 inline med_int* MEDSKYLINEARRAY::getValue() const 
53
54         return _value ; 
55 } ;
56 inline med_int MEDSKYLINEARRAY::getNumberOfI(int i) const throw (MEDEXCEPTION)
57 {
58   if (i<1)
59     throw MEDEXCEPTION("MEDSKYLINEARRAY::getNumberOfI : argument must be >= 1");
60   if (i>_count)
61     throw MEDEXCEPTION("MEDSKYLINEARRAY::getNumberOfI : argument is out of range");
62   return _index[i]-_index[i-1] ;
63 } ;
64 inline med_int* MEDSKYLINEARRAY::getI(int i) const throw (MEDEXCEPTION)
65
66     if (i<1)
67       throw MEDEXCEPTION("MEDSKYLINEARRAY::getI : argument must be >= 1");
68     if (i>_count)
69       throw MEDEXCEPTION("MEDSKYLINEARRAY::getI : argument is out of range");
70     return _value+_index[i-1]-1 ; 
71 }
72 inline med_int MEDSKYLINEARRAY::getIJ(int i, int j) const throw (MEDEXCEPTION)
73
74     if (i<1)
75       throw MEDEXCEPTION("MEDSKYLINEARRAY::getIJ : first argument must be >= 1");
76     if (j<1)
77       throw MEDEXCEPTION("MEDSKYLINEARRAY::getIJ : second argument must be >= 1");
78     if (i>_count)
79       throw MEDEXCEPTION("MEDSKYLINEARRAY::getIJ : first argument is out of range") ;
80     if (j>_index[i])
81       throw MEDEXCEPTION("MEDSKYLINEARRAY::getIJ : second argument is out of range") ;
82     return _value[_index[i-1]+j-2] ;
83 }
84
85
86 # endif