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