Commit b5b2127d authored by Kenneth Leiter's avatar Kenneth Leiter

ENH: Use unsigned ints where appropriate (sizes, indices, etc.)

parent 4a0e2da2
......@@ -26,7 +26,7 @@ public:
class XdmfArray::CopyArrayValues : public boost::static_visitor <void> {
public:
CopyArrayValues(const int startIndex, const int valuesStartIndex, const int numValues, const int arrayStride, const int valuesStride) :
CopyArrayValues(const unsigned int startIndex, const unsigned int valuesStartIndex, const unsigned int numValues, const unsigned int arrayStride, const unsigned int valuesStride) :
mStartIndex(startIndex),
mValuesStartIndex(valuesStartIndex),
mNumValues(numValues),
......@@ -38,7 +38,7 @@ public:
template<typename T, typename U>
void operator()(const boost::shared_ptr<std::vector<T> > & array, const boost::shared_ptr<std::vector<U> > & arrayToCopy) const
{
int size = mStartIndex + mNumValues;
unsigned int size = mStartIndex + mNumValues;
if(mArrayStride > 1)
{
size = mStartIndex + mNumValues * mArrayStride - 1;
......@@ -55,11 +55,11 @@ public:
private:
const int mStartIndex;
const int mValuesStartIndex;
const int mNumValues;
const int mArrayStride;
const int mValuesStride;
const unsigned int mStartIndex;
const unsigned int mValuesStartIndex;
const unsigned int mNumValues;
const unsigned int mArrayStride;
const unsigned int mValuesStride;
};
class XdmfArray::GetCapacity : public boost::static_visitor <unsigned int> {
......@@ -141,66 +141,66 @@ public:
}
};
class XdmfArray::GetPrecision : public boost::static_visitor <int> {
class XdmfArray::GetPrecision : public boost::static_visitor <unsigned int> {
public:
GetPrecision()
{
}
int getPrecision(const char * const) const
unsigned int getPrecision(const char * const) const
{
return 1;
}
int getPrecision(const short * const) const
unsigned int getPrecision(const short * const) const
{
return 2;
}
int getPrecision(const int * const) const
unsigned int getPrecision(const int * const) const
{
return 4;
}
int getPrecision(const long * const) const
unsigned int getPrecision(const long * const) const
{
return 8;
}
int getPrecision(const float * const) const
unsigned int getPrecision(const float * const) const
{
return 4;
}
int getPrecision(const double * const) const
unsigned int getPrecision(const double * const) const
{
return 8;
}
int getPrecision(const unsigned char * const) const
unsigned int getPrecision(const unsigned char * const) const
{
return 1;
}
int getPrecision(const unsigned short * const) const
unsigned int getPrecision(const unsigned short * const) const
{
return 2;
}
int getPrecision(const unsigned int * const) const
unsigned int getPrecision(const unsigned int * const) const
{
return 4;
}
template<typename T>
int operator()(const boost::shared_ptr<std::vector<T> > & array) const
unsigned int operator()(const boost::shared_ptr<std::vector<T> > & array) const
{
return this->getPrecision(&(array.get()->operator[](0)));
}
template<typename T>
int operator()(const boost::shared_array<const T> & array) const
unsigned int operator()(const boost::shared_array<const T> & array) const
{
return this->getPrecision(array.get());
}
......@@ -271,7 +271,7 @@ public:
}
};
class XdmfArray::GetSize : public boost::static_visitor <int> {
class XdmfArray::GetSize : public boost::static_visitor <unsigned int> {
public:
GetSize()
......@@ -279,7 +279,7 @@ public:
}
template<typename T>
int operator()(const boost::shared_ptr<std::vector<T> > & array) const
unsigned int operator()(const boost::shared_ptr<std::vector<T> > & array) const
{
return array->size();
}
......@@ -348,7 +348,7 @@ public:
private:
const int mArrayPointerNumValues;
const unsigned int mArrayPointerNumValues;
};
class XdmfArray::InternalizeArrayPointer : public boost::static_visitor <void> {
......@@ -421,7 +421,7 @@ XdmfArray::~XdmfArray()
std::cout << "Deleted Array " << this << std::endl;
}
void XdmfArray::copyValues(const int startIndex, const boost::shared_ptr<const XdmfArray> values, const int valuesStartIndex, const int numValues, const int arrayStride, const int valuesStride)
void XdmfArray::copyValues(const unsigned int startIndex, const boost::shared_ptr<const XdmfArray> values, const unsigned int valuesStartIndex, const unsigned int numValues, const unsigned int arrayStride, const unsigned int valuesStride)
{
if(mHaveArrayPointer)
{
......@@ -468,7 +468,7 @@ hid_t XdmfArray::getHDF5Type() const
return -1;
}
int XdmfArray::getPrecision() const
unsigned int XdmfArray::getPrecision() const
{
if(mHaveArray)
{
......@@ -481,7 +481,7 @@ int XdmfArray::getPrecision() const
return 0;
}
int XdmfArray::getSize() const
unsigned int XdmfArray::getSize() const
{
if(mHaveArray)
{
......
......@@ -58,7 +58,7 @@ public:
* @param arrayStride number of values to stride in this array between each copy.
* @param valuesStride number of values to stride in the XdmfArray between each copy.
*/
void copyValues(const int startIndex, const boost::shared_ptr<const XdmfArray> values, const int valuesStartIndex= 0, const int numValues = 1, const int arrayStride = 1, const int valuesStride = 1);
void copyValues(const unsigned int startIndex, const boost::shared_ptr<const XdmfArray> values, const unsigned int valuesStartIndex= 0, const unsigned int numValues = 1, const unsigned int arrayStride = 1, const unsigned int valuesStride = 1);
/**
* Copy values from an array into this array.
......@@ -70,7 +70,7 @@ public:
* @param valuesStride number of values to stride in the pointer between each copy.
*/
template<typename T>
void copyValues(const int startIndex, const T * const valuesPointer, const int numValues = 1, const int arrayStride = 1, const int valuesStride = 1);
void copyValues(const unsigned int startIndex, const T * const valuesPointer, const unsigned int numValues = 1, const unsigned int arrayStride = 1, const unsigned int valuesStride = 1);
/**
* Remove all values from this array
......@@ -79,29 +79,31 @@ public:
/**
* Get the capacity of this array (the number of values this array can store without reallocation).
*
* @return the capacity of this array.
*/
unsigned int getCapacity() const;
/**
* Get the hdf5 data type of this array.
*
* @return a hid_t value containing the hdf5 data type for the array.
* @return the hdf5 data type for the array.
*/
virtual hid_t getHDF5Type() const;
/**
* Get the precision, in bytes, of the data type of this array.
*
* @return an int containing the precision, in bytes, of the data type of this array.
* @return the precision, in bytes, of the data type of this array.
*/
virtual int getPrecision() const;
virtual unsigned int getPrecision() const;
/**
* Get the number of values stored in this array.
*
* @return an int containing the number of values stored in this array.
* @return the number of values stored in this array.
*/
virtual int getSize() const;
virtual unsigned int getSize() const;
/**
* Get the data type of this array.
......@@ -192,7 +194,7 @@ public:
* @param transferOwnership whether to transfer responsibility for deletion of the array to XdmfArray.
*/
template<typename T>
void setValues(const T * const arrayPointer, const int numValues, const bool transferOwnership = 0);
void setValues(const T * const arrayPointer, const unsigned int numValues, const bool transferOwnership = 0);
/**
* Sets the values of this array to the values stored in the vector. No copy is made. The caller of this method retains
......@@ -315,10 +317,10 @@ private:
ArrayVariant mArray;
ArrayPointerVariant mArrayPointer;
int mArrayPointerNumValues;
unsigned int mArrayPointerNumValues;
bool mHaveArray;
bool mHaveArrayPointer;
int mTmpReserveSize;
unsigned int mTmpReserveSize;
};
#include "XdmfArray.tpp"
......
......@@ -5,7 +5,7 @@ template<typename T>
class XdmfArray::CopyValues : public boost::static_visitor <void> {
public:
CopyValues(const int startIndex, const T * const valuesPointer, const int numValues, const int arrayStride, const int valuesStride) :
CopyValues(const unsigned int startIndex, const T * const valuesPointer, const unsigned int numValues, const unsigned int arrayStride, const unsigned int valuesStride) :
mStartIndex(startIndex),
mValuesPointer(valuesPointer),
mNumValues(numValues),
......@@ -17,7 +17,7 @@ public:
template<typename U>
void operator()(boost::shared_ptr<std::vector<U> > & array) const
{
int size = mStartIndex + mNumValues;
unsigned int size = mStartIndex + mNumValues;
if(mArrayStride > 1)
{
size = mStartIndex + mNumValues * mArrayStride - 1;
......@@ -34,11 +34,11 @@ public:
private:
const int mStartIndex;
const unsigned int mStartIndex;
const T * const mValuesPointer;
const int mNumValues;
const int mArrayStride;
const int mValuesStride;
const unsigned int mNumValues;
const unsigned int mArrayStride;
const unsigned int mValuesStride;
};
template<typename T>
......@@ -71,7 +71,7 @@ struct XdmfArray::NullDeleter
};
template<typename T>
void XdmfArray::copyValues(const int startIndex, const T * const valuesPointer, const int numValues, const int arrayStride, const int valuesStride)
void XdmfArray::copyValues(const unsigned int startIndex, const T * const valuesPointer, const unsigned int numValues, const unsigned int arrayStride, const unsigned int valuesStride)
{
if(mHaveArrayPointer)
{
......@@ -150,7 +150,7 @@ void XdmfArray::resize(const unsigned int numValues, const T & val)
}
template<typename T>
void XdmfArray::setValues(const T * const arrayPointer, const int numValues, const bool transferOwnership)
void XdmfArray::setValues(const T * const arrayPointer, const unsigned int numValues, const bool transferOwnership)
{
// Remove contents of internal array.
if(mHaveArray)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment