1 # ifndef __MEDSKYLINEARRAY_H__
2 # define __MEDSKYLINEARRAY_H__
4 #include "MEDMEM_Exception.hxx"
6 #include "MEDMEM_PointerOf.hxx"
7 #include "MEDMEM_define.hxx"
15 PointerOf <int> _index ; // array of size _count+1 : _index[0]=1 and
16 // _index[_count]=length+1
17 PointerOf <int> _value ; // array of size _length
22 MEDSKYLINEARRAY( const MEDSKYLINEARRAY &myArray );
23 MEDSKYLINEARRAY( const int count, const int length );
24 MEDSKYLINEARRAY( const int count, const int length,
25 const int* index, const int* value, bool shallowCopy=false );
27 //void setMEDSKYLINEARRAY( const int count, const int length, int* index , int* value ) ;
29 inline int getNumberOf() const;
30 inline int getLength() const;
31 inline const int* getIndex() const;
32 inline const int* getValue() const;
33 inline int getNumberOfI(int i) const throw (MEDEXCEPTION) ;
34 inline const int* getI(int i) const throw (MEDEXCEPTION) ;
35 inline int getIJ(int i, int j) const throw (MEDEXCEPTION) ;
36 inline int getIndexValue(int i) const throw (MEDEXCEPTION) ;
38 inline void setIndex(const int* index) ;
39 inline void setI(const int i, const int* values) throw (MEDEXCEPTION) ;
40 inline void setIJ(int i, int j, int value) throw (MEDEXCEPTION) ;
41 inline void setIndexValue(int i, int value) throw (MEDEXCEPTION) ;
45 // ---------------------------------------
47 // ---------------------------------------
48 inline int MEDSKYLINEARRAY::getNumberOf() const
52 inline int MEDSKYLINEARRAY::getLength() const
56 inline const int* MEDSKYLINEARRAY::getIndex() const
58 return (const int*)_index ;
60 inline const int* MEDSKYLINEARRAY::getValue() const
62 return (const int*)_value ;
64 inline int MEDSKYLINEARRAY::getNumberOfI(int i) const throw (MEDEXCEPTION)
67 throw MEDEXCEPTION("MEDSKYLINEARRAY::getNumberOfI : argument must be >= 1");
69 throw MEDEXCEPTION("MEDSKYLINEARRAY::getNumberOfI : argument is out of range");
70 return _index[i]-_index[i-1] ;
72 inline const int* MEDSKYLINEARRAY::getI(int i) const throw (MEDEXCEPTION)
75 throw MEDEXCEPTION("MEDSKYLINEARRAY::getI : argument must be >= 1");
77 throw MEDEXCEPTION("MEDSKYLINEARRAY::getI : argument is out of range");
78 return _value+_index[i-1]-1 ;
80 inline int MEDSKYLINEARRAY::getIJ(int i, int j) const throw (MEDEXCEPTION)
83 throw MEDEXCEPTION("MEDSKYLINEARRAY::getIJ : first argument must be >= 1");
85 throw MEDEXCEPTION("MEDSKYLINEARRAY::getIJ : second argument must be >= 1");
87 throw MEDEXCEPTION("MEDSKYLINEARRAY::getIJ : first argument is out of range") ;
89 throw MEDEXCEPTION("MEDSKYLINEARRAY::getIJ : second argument is out of range") ;
90 return _value[_index[i-1]+j-2] ;
93 inline int MEDSKYLINEARRAY::getIndexValue(int i) const throw (MEDEXCEPTION)
96 throw MEDEXCEPTION("MEDSKYLINEARRAY::getIndexValue : argument must be >= 1");
98 throw MEDEXCEPTION("MEDSKYLINEARRAY::getIndexValue : argument is out of range") ;
102 inline void MEDSKYLINEARRAY::setIndex(const int* index)
104 memcpy((int*)_index,index,(_count+1)*sizeof(int));
108 inline void MEDSKYLINEARRAY::setIJ(int i, int j, int value) throw (MEDEXCEPTION)
111 throw MEDEXCEPTION("MEDSKYLINEARRAY::setIJ : first argument must be >= 1");
113 throw MEDEXCEPTION("MEDSKYLINEARRAY::setIJ : second argument must be >= 1");
115 throw MEDEXCEPTION("MEDSKYLINEARRAY::setIJ : first argument is out of range") ;
117 throw MEDEXCEPTION("MEDSKYLINEARRAY::setIJ : second argument is out of range") ;
119 _value[_index[i-1]+j-2]=value ;
123 inline void MEDSKYLINEARRAY::setI(const int i, const int * values) throw (MEDEXCEPTION)
126 throw MEDEXCEPTION("MEDSKYLINEARRAY::setI : index must be >= 1");
129 throw MEDEXCEPTION("MEDSKYLINEARRAY::setI : index is out of range") ;
131 memcpy(_value+_index[i-1]-1,values,(_index[i]-_index[i-1])*sizeof(int)) ;
134 inline void MEDSKYLINEARRAY::setIndexValue(int i, int value) throw (MEDEXCEPTION)
137 throw MEDEXCEPTION("MEDSKYLINEARRAY::setIndexValue : argument must be >= 1");
138 if (i>_index[_count])
139 throw MEDEXCEPTION("MEDSKYLINEARRAY::setIndexValue : argument is out of range") ;