1 # ifndef __MEDSKYLINEARRAY_H__
2 # define __MEDSKYLINEARRAY_H__
4 #include "MEDMEM_Exception.hxx"
6 #include "MEDMEM_PointerOf.hxx"
7 #include "MEDMEM_define.hxx"
17 PointerOf <med_int> _index ; // array of size _count+1 : _index[0]=1 and
18 // _index[_count]=length+1
19 PointerOf <med_int> _value ; // array of size _length
24 MEDSKYLINEARRAY( const MEDSKYLINEARRAY &myArray );
25 MEDSKYLINEARRAY( const med_int count, const med_int length );
26 MEDSKYLINEARRAY( const med_int count, const med_int length,
27 const med_int* index, const med_int* value );
29 //void setMEDSKYLINEARRAY( const med_int count, const med_int length, med_int* index , med_int* value ) ;
31 inline med_int getNumberOf() const;
32 inline med_int getLength() const;
33 inline const med_int* getIndex() const;
34 inline const med_int* getValue() const;
35 inline med_int getNumberOfI(int i) const throw (MEDEXCEPTION) ;
36 inline const med_int* getI(int i) const throw (MEDEXCEPTION) ;
37 inline med_int getIJ(int i, int j) const throw (MEDEXCEPTION) ;
38 inline med_int getIndexValue(int i) const throw (MEDEXCEPTION) ;
40 inline void setIndex(const med_int* index) ;
41 inline void setI(const med_int i, const med_int* values) throw (MEDEXCEPTION) ;
42 inline void setIJ(med_int i, med_int j, med_int value) throw (MEDEXCEPTION) ;
43 inline void setIndexValue(med_int i, med_int value) throw (MEDEXCEPTION) ;
47 using namespace MEDMEM;
48 // ---------------------------------------
50 // ---------------------------------------
51 inline med_int MEDSKYLINEARRAY::getNumberOf() const
55 inline med_int MEDSKYLINEARRAY::getLength() const
59 inline const med_int* MEDSKYLINEARRAY::getIndex() const
61 return (const med_int*)_index ;
63 inline const med_int* MEDSKYLINEARRAY::getValue() const
65 return (const med_int*)_value ;
67 inline med_int MEDSKYLINEARRAY::getNumberOfI(int i) const throw (MEDEXCEPTION)
70 throw MEDEXCEPTION("MEDSKYLINEARRAY::getNumberOfI : argument must be >= 1");
72 throw MEDEXCEPTION("MEDSKYLINEARRAY::getNumberOfI : argument is out of range");
73 return _index[i]-_index[i-1] ;
75 inline const med_int* MEDSKYLINEARRAY::getI(int i) const throw (MEDEXCEPTION)
78 throw MEDEXCEPTION("MEDSKYLINEARRAY::getI : argument must be >= 1");
80 throw MEDEXCEPTION("MEDSKYLINEARRAY::getI : argument is out of range");
81 return _value+_index[i-1]-1 ;
83 inline med_int MEDSKYLINEARRAY::getIJ(int i, int j) const throw (MEDEXCEPTION)
86 throw MEDEXCEPTION("MEDSKYLINEARRAY::getIJ : first argument must be >= 1");
88 throw MEDEXCEPTION("MEDSKYLINEARRAY::getIJ : second argument must be >= 1");
90 throw MEDEXCEPTION("MEDSKYLINEARRAY::getIJ : first argument is out of range") ;
92 throw MEDEXCEPTION("MEDSKYLINEARRAY::getIJ : second argument is out of range") ;
93 return _value[_index[i-1]+j-2] ;
96 inline med_int MEDSKYLINEARRAY::getIndexValue(int i) const throw (MEDEXCEPTION)
99 throw MEDEXCEPTION("MEDSKYLINEARRAY::getIndexValue : argument must be >= 1");
100 if (i>_index[_count])
101 throw MEDEXCEPTION("MEDSKYLINEARRAY::getIndexValue : argument is out of range") ;
105 inline void MEDSKYLINEARRAY::setIndex(const med_int* index)
107 memcpy((med_int*)_index,index,(_count+1)*sizeof(med_int));
111 inline void MEDSKYLINEARRAY::setIJ(med_int i, med_int j, med_int value) throw (MEDEXCEPTION)
114 throw MEDEXCEPTION("MEDSKYLINEARRAY::setIJ : first argument must be >= 1");
116 throw MEDEXCEPTION("MEDSKYLINEARRAY::setIJ : second argument must be >= 1");
118 throw MEDEXCEPTION("MEDSKYLINEARRAY::setIJ : first argument is out of range") ;
120 throw MEDEXCEPTION("MEDSKYLINEARRAY::setIJ : second argument is out of range") ;
122 _value[_index[i-1]+j-2]=value ;
126 inline void MEDSKYLINEARRAY::setI(const med_int i, const med_int * values) throw (MEDEXCEPTION)
129 throw MEDEXCEPTION("MEDSKYLINEARRAY::setI : index must be >= 1");
132 throw MEDEXCEPTION("MEDSKYLINEARRAY::setI : index is out of range") ;
134 memcpy(_value+_index[i-1]-1,values,(_index[i]-_index[i-1])*sizeof(med_int)) ;
137 inline void MEDSKYLINEARRAY::setIndexValue(med_int i, med_int value) throw (MEDEXCEPTION)
140 throw MEDEXCEPTION("MEDSKYLINEARRAY::setIndexValue : argument must be >= 1");
141 if (i>_index[_count])
142 throw MEDEXCEPTION("MEDSKYLINEARRAY::setIndexValue : argument is out of range") ;