1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-16 10:08:36 +03:00

0023373: MSVC++ warnings issued during compilation for 64bits, 'Sparse Arrays'

Replaced 'Standard_Integer' with 'Standard_Size' to avoid compiler warning.
Removed redundant casting to 'Standard_Size'.
Removed code checking if a 'Standard_Size' variable is negative.
This commit is contained in:
Pawel 2012-08-24 14:18:55 +04:00
parent 6318e884de
commit d93f7683c9
5 changed files with 38 additions and 42 deletions

View File

@ -85,31 +85,31 @@ public:
//!@{ //!@{
//! Direct const access to the item //! Direct const access to the item
const TheItemType& Value (const Standard_Integer theIndex) const const TheItemType& Value (const Standard_Size theIndex) const
{ {
return *(const TheItemType*)this->getValue(theIndex); return *(const TheItemType*)this->getValue(theIndex);
} }
//! Const access to the item - operator() //! Const access to the item - operator()
const TheItemType& operator () (const Standard_Integer theIndex) const const TheItemType& operator () (const Standard_Size theIndex) const
{ {
return Value (theIndex); return Value (theIndex);
} }
//! Modification access to the item //! Modification access to the item
TheItemType& ChangeValue (const Standard_Integer theIndex) TheItemType& ChangeValue (const Standard_Size theIndex)
{ {
return *(TheItemType*)(this->getValue (theIndex)); return *(TheItemType*)(this->getValue (theIndex));
} }
//! Access to the item - operator() //! Access to the item - operator()
TheItemType& operator () (const Standard_Integer theIndex) TheItemType& operator () (const Standard_Size theIndex)
{ {
return ChangeValue (theIndex); return ChangeValue (theIndex);
} }
//! Set a value at specified index method //! Set a value at specified index method
TheItemType& SetValue (const Standard_Integer theIndex, TheItemType& SetValue (const Standard_Size theIndex,
const TheItemType& theValue) const TheItemType& theValue)
{ {
return *(TheItemType*)this->setValue(theIndex, (Standard_Address)&theValue); return *(TheItemType*)this->setValue(theIndex, (Standard_Address)&theValue);
@ -134,33 +134,33 @@ public:
} }
//! Direct const access to the item //! Direct const access to the item
const TheItemType& Find (const Standard_Integer theIndex) const const TheItemType& Find (const Standard_Size theIndex) const
{ {
return *(TheItemType*)this->getValue(theIndex); return *(TheItemType*)this->getValue(theIndex);
} }
//! Modification access to the item; allocates space if //! Modification access to the item; allocates space if
//! necessary and marks the item as defined //! necessary and marks the item as defined
TheItemType& ChangeFind (const Standard_Integer theIndex) TheItemType& ChangeFind (const Standard_Size theIndex)
{ {
return *(TheItemType*)(this->changeValue (theIndex)); return *(TheItemType*)(this->changeValue (theIndex));
} }
//! Set a value as explicit method //! Set a value as explicit method
TheItemType& Bind (const Standard_Integer theIndex, TheItemType& Bind (const Standard_Size theIndex,
const TheItemType& theValue) const TheItemType& theValue)
{ {
return SetValue(theIndex, theValue); return SetValue(theIndex, theValue);
} }
//! Returns True if the item is defined //! Returns True if the item is defined
Standard_Boolean IsBound (const Standard_Integer theIndex) const Standard_Boolean IsBound (const Standard_Size theIndex) const
{ {
return this->HasValue(theIndex); return this->HasValue(theIndex);
} }
//! Remove the item from array //! Remove the item from array
Standard_Boolean UnBind (const Standard_Integer theIndex) Standard_Boolean UnBind (const Standard_Size theIndex)
{ {
return this->UnsetValue(theIndex); return this->UnsetValue(theIndex);
} }
@ -203,7 +203,7 @@ public:
} }
//! Access current index with 'a-la map' interface //! Access current index with 'a-la map' interface
Standard_Integer Key (void) const { return Index(); } Standard_Size Key (void) const { return Index(); }
}; };
/** /**

View File

@ -202,12 +202,10 @@ void NCollection_SparseArrayBase::exchange (NCollection_SparseArrayBase& theOthe
//purpose : //purpose :
//======================================================================= //=======================================================================
Standard_Address NCollection_SparseArrayBase::setValue (const Standard_Integer theIndex, Standard_Address NCollection_SparseArrayBase::setValue (const Standard_Size theIndex,
const Standard_Address theValue) const Standard_Address theValue)
{ {
Standard_OutOfRange_Raise_if (theIndex<0,"NCollection_SparseArray::SetValue()") Standard_Size iBlock = theIndex / myBlockSize;
Standard_Size anIndex = (Standard_Size)theIndex;
Standard_Size iBlock = anIndex / myBlockSize;
// resize blocks array if necessary // resize blocks array if necessary
if ( iBlock >= myNbBlocks ) if ( iBlock >= myNbBlocks )
@ -222,7 +220,7 @@ Standard_Address NCollection_SparseArrayBase::setValue (const Standard_Integer t
Block aBlock (getBlock (anAddr)); Block aBlock (getBlock (anAddr));
// mark item as defined // mark item as defined
Standard_Size anInd = anIndex % myBlockSize; Standard_Size anInd = theIndex % myBlockSize;
Standard_Address anItem = getItem (aBlock, anInd); Standard_Address anItem = getItem (aBlock, anInd);
// either create an item by copy constructor if it is new, or assign it // either create an item by copy constructor if it is new, or assign it
@ -243,14 +241,13 @@ Standard_Address NCollection_SparseArrayBase::setValue (const Standard_Integer t
//purpose : //purpose :
//======================================================================= //=======================================================================
Standard_Boolean NCollection_SparseArrayBase::HasValue (const Standard_Integer theIndex) const Standard_Boolean NCollection_SparseArrayBase::HasValue (const Standard_Size theIndex) const
{ {
Standard_Size anIndex = (Standard_Size)theIndex; Standard_Size iBlock = theIndex / myBlockSize;
Standard_Size iBlock = anIndex / myBlockSize; if ( iBlock >= myNbBlocks ||
if ( theIndex < 0 || iBlock >= myNbBlocks ||
! myData[iBlock] ) ! myData[iBlock] )
return Standard_False; return Standard_False;
return getBlock(myData[iBlock]).IsSet(anIndex % myBlockSize) ? Standard_True : Standard_False; return getBlock(myData[iBlock]).IsSet(theIndex % myBlockSize) ? Standard_True : Standard_False;
} }
//======================================================================= //=======================================================================
@ -258,16 +255,15 @@ Standard_Boolean NCollection_SparseArrayBase::HasValue (const Standard_Integer t
//purpose : //purpose :
//======================================================================= //=======================================================================
Standard_Boolean NCollection_SparseArrayBase::UnsetValue (const Standard_Integer theIndex) Standard_Boolean NCollection_SparseArrayBase::UnsetValue (const Standard_Size theIndex)
{ {
// check that the item is defined // check that the item is defined
Standard_Size anIndex = (Standard_Size)theIndex; Standard_Size iBlock = theIndex / myBlockSize;
Standard_Size iBlock = anIndex / myBlockSize; if ( iBlock >= myNbBlocks || ! myData[iBlock] )
if ( theIndex < 0 || iBlock >= myNbBlocks || ! myData[iBlock] )
return Standard_False; return Standard_False;
Block aBlock (getBlock(myData[iBlock])); Block aBlock (getBlock(myData[iBlock]));
Standard_Size anInd = anIndex % myBlockSize; Standard_Size anInd = theIndex % myBlockSize;
if ( ! aBlock.Unset(anInd) ) if ( ! aBlock.Unset(anInd) )
return Standard_False; return Standard_False;

View File

@ -45,11 +45,11 @@ public:
Standard_Size Size () const { return mySize; } Standard_Size Size () const { return mySize; }
//! Check whether the value at given index is set //! Check whether the value at given index is set
Standard_EXPORT Standard_Boolean HasValue (const Standard_Integer theIndex) const; Standard_EXPORT Standard_Boolean HasValue (const Standard_Size theIndex) const;
//! Deletes the item from the array; //! Deletes the item from the array;
//! returns True if that item was defined //! returns True if that item was defined
Standard_EXPORT Standard_Boolean UnsetValue (const Standard_Integer theIndex); Standard_EXPORT Standard_Boolean UnsetValue (const Standard_Size theIndex);
//!@} //!@}
@ -231,7 +231,7 @@ protected:
} }
//! Direct const access to the item //! Direct const access to the item
Standard_Address getValue (const Standard_Integer theIndex) const Standard_Address getValue (const Standard_Size theIndex) const
{ {
Standard_OutOfRange_Raise_if (!HasValue(theIndex),"NCollection_SparseArray::Value()") Standard_OutOfRange_Raise_if (!HasValue(theIndex),"NCollection_SparseArray::Value()")
return Block::ToArray(myData[theIndex/myBlockSize], myBlockSize, myItemSize) + return Block::ToArray(myData[theIndex/myBlockSize], myBlockSize, myItemSize) +
@ -239,12 +239,12 @@ protected:
} }
//! Set a value to the specified item; returns address of the set item //! Set a value to the specified item; returns address of the set item
Standard_EXPORT Standard_Address setValue (const Standard_Integer theIndex, Standard_EXPORT Standard_Address setValue (const Standard_Size theIndex,
const Standard_Address theValue); const Standard_Address theValue);
//! Modification access to the item; allocates necessary space //! Modification access to the item; allocates necessary space
//! and marks the item as defined //! and marks the item as defined
Standard_EXPORT Standard_Address changeValue (const Standard_Integer theIndex); Standard_EXPORT Standard_Address changeValue (const Standard_Size theIndex);
//! Copy contents of theOther to this; //! Copy contents of theOther to this;
//! assumes that this and theOther have exactly the same type of arguments //! assumes that this and theOther have exactly the same type of arguments

View File

@ -82,7 +82,7 @@ Handle(TObj_TIntSparseArray) TObj_TIntSparseArray::Set
//purpose : //purpose :
//======================================================================= //=======================================================================
void TObj_TIntSparseArray::SetValue (const Standard_Integer theId, void TObj_TIntSparseArray::SetValue (const Standard_Size theId,
const Standard_Integer theValue) const Standard_Integer theValue)
{ {
// check that modification is allowed // check that modification is allowed
@ -128,7 +128,7 @@ void TObj_TIntSparseArray::SetValue (const Standard_Integer theId,
//purpose : //purpose :
//======================================================================= //=======================================================================
void TObj_TIntSparseArray::UnsetValue (const Standard_Integer theId) void TObj_TIntSparseArray::UnsetValue (const Standard_Size theId)
{ {
// check that modification is allowed // check that modification is allowed
if ( !Label().Data()->IsModificationAllowed() ) if ( !Label().Data()->IsModificationAllowed() )
@ -182,7 +182,7 @@ void TObj_TIntSparseArray::Clear ()
TObj_TIntSparseArray_VecOfData::Iterator anIt (myVector); TObj_TIntSparseArray_VecOfData::Iterator anIt (myVector);
for (; anIt.More(); anIt.Next()) for (; anIt.More(); anIt.Next())
{ {
Standard_Integer anId = anIt.Key(); Standard_Size anId = anIt.Key();
Standard_Integer aVal = anIt.Value(); Standard_Integer aVal = anIt.Value();
backupValue(anId, aVal, AbsentValue); backupValue(anId, aVal, AbsentValue);
} }
@ -196,7 +196,7 @@ void TObj_TIntSparseArray::Clear ()
//purpose : //purpose :
//======================================================================= //=======================================================================
void TObj_TIntSparseArray::backupValue (const Standard_Integer theId, void TObj_TIntSparseArray::backupValue (const Standard_Size theId,
const Standard_Integer theCurrValue, const Standard_Integer theCurrValue,
const Standard_Integer theNewValue) const Standard_Integer theNewValue)
{ {
@ -257,7 +257,7 @@ void TObj_TIntSparseArray::Restore(const Handle(TDF_Attribute)& theDelta)
TObj_TIntSparseArray_MapOfData::Iterator anIt (aDelta->myOldMap); TObj_TIntSparseArray_MapOfData::Iterator anIt (aDelta->myOldMap);
for (; anIt.More(); anIt.Next()) for (; anIt.More(); anIt.Next())
{ {
Standard_Integer anId = anIt.Key(); Standard_Size anId = anIt.Key();
Standard_Integer anOld = anIt.Value(); Standard_Integer anOld = anIt.Value();
if (anOld == AbsentValue) if (anOld == AbsentValue)
UnsetValue (anId); UnsetValue (anId);

View File

@ -62,7 +62,7 @@ class TObj_TIntSparseArray : public TDF_Attribute
//! Methods for access to data //! Methods for access to data
//! Returns the number of stored values in the set //! Returns the number of stored values in the set
Standard_EXPORT Standard_Integer Size() const Standard_EXPORT Standard_Size Size() const
{ return myVector.Size(); } { return myVector.Size(); }
typedef TObj_TIntSparseArray_VecOfData::ConstIterator Iterator; typedef TObj_TIntSparseArray_VecOfData::ConstIterator Iterator;
@ -71,22 +71,22 @@ class TObj_TIntSparseArray : public TDF_Attribute
Iterator GetIterator() const { return Iterator(myVector); } Iterator GetIterator() const { return Iterator(myVector); }
//! Returns true if the value with the given ID is present. //! Returns true if the value with the given ID is present.
Standard_Boolean HasValue (const Standard_Integer theId) const Standard_Boolean HasValue (const Standard_Size theId) const
{ return myVector.HasValue(theId); } { return myVector.HasValue(theId); }
//! Returns the value by its ID. //! Returns the value by its ID.
//! Raises an exception if no value is stored with this ID //! Raises an exception if no value is stored with this ID
Standard_Integer Value (const Standard_Integer theId) const Standard_Integer Value (const Standard_Size theId) const
{ return myVector.Value(theId); } { return myVector.Value(theId); }
//! Sets the value with the given ID. //! Sets the value with the given ID.
//! Raises an exception if theId is not positive //! Raises an exception if theId is not positive
Standard_EXPORT void SetValue (const Standard_Integer theId, Standard_EXPORT void SetValue (const Standard_Size theId,
const Standard_Integer theValue); const Standard_Integer theValue);
//! Unsets the value with the given ID. //! Unsets the value with the given ID.
//! Raises an exception if theId is not positive //! Raises an exception if theId is not positive
Standard_EXPORT void UnsetValue(const Standard_Integer theId); Standard_EXPORT void UnsetValue(const Standard_Size theId);
//! Clears the set //! Clears the set
Standard_EXPORT void Clear (); Standard_EXPORT void Clear ();
@ -142,7 +142,7 @@ class TObj_TIntSparseArray : public TDF_Attribute
}; };
//! backup one value //! backup one value
void backupValue (const Standard_Integer theId, void backupValue (const Standard_Size theId,
const Standard_Integer theCurrValue, const Standard_Integer theCurrValue,
const Standard_Integer theNewValue); const Standard_Integer theNewValue);