1 # ifndef __MEDSKYLINEARRAY_H__
2 # define __MEDSKYLINEARRAY_H__
4 #include "MEDMEM_Exception.hxx"
6 #include "MEDMEM_PointerOf.hxx"
7 #include "MEDMEM_define.hxx"
9 using MED_EN::med_int ;
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
23 MEDSKYLINEARRAY( const MEDSKYLINEARRAY &myArray );
24 MEDSKYLINEARRAY( const med_int count, const med_int length );
25 MEDSKYLINEARRAY( const med_int count, const med_int length,
26 const med_int* index, const med_int* value );
28 //void setMEDSKYLINEARRAY( const med_int count, const med_int length, med_int* index , med_int* value ) ;
30 inline med_int getNumberOf() const;
31 inline med_int getLength() const;
32 inline const med_int* getIndex() const;
33 inline const med_int* getValue() const;
34 inline med_int getNumberOfI(int i) const throw (MEDEXCEPTION) ;
35 inline const med_int* getI(int i) const throw (MEDEXCEPTION) ;
36 inline med_int getIJ(int i, int j) const throw (MEDEXCEPTION) ;
37 inline med_int getIndexValue(int i) const throw (MEDEXCEPTION) ;
39 inline void setIndex(const med_int* index) ;
40 inline void setI(const med_int i, const med_int* values) throw (MEDEXCEPTION) ;
41 inline void setIJ(med_int i, med_int j, med_int value) throw (MEDEXCEPTION) ;
42 inline void setIndexValue(med_int i, med_int value) throw (MEDEXCEPTION) ;
46 // ---------------------------------------
48 // ---------------------------------------
49 inline med_int MEDSKYLINEARRAY::getNumberOf() const
53 inline med_int MEDSKYLINEARRAY::getLength() const
57 inline const med_int* MEDSKYLINEARRAY::getIndex() const
59 return (const med_int*)_index ;
61 inline const med_int* MEDSKYLINEARRAY::getValue() const
63 return (const med_int*)_value ;
65 inline med_int MEDSKYLINEARRAY::getNumberOfI(int i) const throw (MEDEXCEPTION)
68 throw MEDEXCEPTION("MEDSKYLINEARRAY::getNumberOfI : argument must be >= 1");
70 throw MEDEXCEPTION("MEDSKYLINEARRAY::getNumberOfI : argument is out of range");
71 return _index[i]-_index[i-1] ;
73 inline const med_int* MEDSKYLINEARRAY::getI(int i) const throw (MEDEXCEPTION)
76 throw MEDEXCEPTION("MEDSKYLINEARRAY::getI : argument must be >= 1");
78 throw MEDEXCEPTION("MEDSKYLINEARRAY::getI : argument is out of range");
79 return _value+_index[i-1]-1 ;
81 inline med_int MEDSKYLINEARRAY::getIJ(int i, int j) const throw (MEDEXCEPTION)
84 throw MEDEXCEPTION("MEDSKYLINEARRAY::getIJ : first argument must be >= 1");
86 throw MEDEXCEPTION("MEDSKYLINEARRAY::getIJ : second argument must be >= 1");
88 throw MEDEXCEPTION("MEDSKYLINEARRAY::getIJ : first argument is out of range") ;
90 throw MEDEXCEPTION("MEDSKYLINEARRAY::getIJ : second argument is out of range") ;
91 return _value[_index[i-1]+j-2] ;
94 inline med_int MEDSKYLINEARRAY::getIndexValue(int i) const throw (MEDEXCEPTION)
97 throw MEDEXCEPTION("MEDSKYLINEARRAY::getIndexValue : argument must be >= 1");
99 throw MEDEXCEPTION("MEDSKYLINEARRAY::getIndexValue : argument is out of range") ;
103 inline void MEDSKYLINEARRAY::setIndex(const med_int* index)
105 memcpy((med_int*)_index,index,(_count+1)*sizeof(med_int));
109 inline void MEDSKYLINEARRAY::setIJ(med_int i, med_int j, med_int value) throw (MEDEXCEPTION)
112 throw MEDEXCEPTION("MEDSKYLINEARRAY::setIJ : first argument must be >= 1");
114 throw MEDEXCEPTION("MEDSKYLINEARRAY::setIJ : second argument must be >= 1");
116 throw MEDEXCEPTION("MEDSKYLINEARRAY::setIJ : first argument is out of range") ;
118 throw MEDEXCEPTION("MEDSKYLINEARRAY::setIJ : second argument is out of range") ;
120 _value[_index[i-1]+j-2]=value ;
124 inline void MEDSKYLINEARRAY::setI(const med_int i, const med_int * values) throw (MEDEXCEPTION)
127 throw MEDEXCEPTION("MEDSKYLINEARRAY::setI : index must be >= 1");
130 throw MEDEXCEPTION("MEDSKYLINEARRAY::setI : index is out of range") ;
132 memcpy(_value+_index[i-1]-1,values,(_index[i]-_index[i-1])*sizeof(med_int)) ;
135 inline void MEDSKYLINEARRAY::setIndexValue(med_int i, med_int value) throw (MEDEXCEPTION)
138 throw MEDEXCEPTION("MEDSKYLINEARRAY::setIndexValue : argument must be >= 1");
139 if (i>_index[_count])
140 throw MEDEXCEPTION("MEDSKYLINEARRAY::setIndexValue : argument is out of range") ;