Commit 7e74654a authored by Franjo's avatar Franjo
Browse files

Reverted back to label

parent 60aa093a
......@@ -64,10 +64,9 @@ inline Foam::FRWGraph<T,width>::FRWGraph
const label s
)
:
data_(static_cast<long long>(s) * width),
data_(s * width),
nRows_(s)
{
}
{}
//- Construct given size
......@@ -78,7 +77,7 @@ inline Foam::FRWGraph<T,width>::FRWGraph
const T& t
)
:
data_(static_cast<long long>(s) * width, t),
data_(s * width, t),
nRows_(s)
{}
......@@ -114,7 +113,7 @@ inline Foam::label Foam::FRWGraph<T,width>::sizeOfRow(const label rowI) const
template<class T, Foam::label width>
inline void Foam::FRWGraph<T,width>::setSize(const label i)
{
data_.setSize(static_cast<long long>(i) * width);
data_.setSize(i * width);
nRows_ = i;
}
......@@ -155,7 +154,7 @@ inline bool Foam::FRWGraph<T,width>::contains
const T& e
) const
{
const long long start = static_cast<long long>(rowI) * width;
const label start = rowI * width;
for(register label i=0;i<width;++i)
if( data_[start+i] == e )
return true;
......@@ -170,7 +169,7 @@ inline Foam::label Foam::FRWGraph<T,width>::containsAtPosition
const T& e
) const
{
const long long start = static_cast<long long>(rowI) * width;
const label start = rowI * width;
for(register label i=0;i<width;++i)
if( data_[start+i] == e )
return i;
......@@ -190,7 +189,7 @@ inline const T& Foam::FRWGraph<T,width>::operator()
checkIndex(i, j);
#endif
return data_[static_cast<long long>(i) * width + j];
return data_[i * width + j];
}
template<class T, Foam::label width>
......@@ -203,7 +202,7 @@ inline T& Foam::FRWGraph<T,width>::operator()
checkIndex(i, j);
#endif
return data_[static_cast<long long>(i) * width + j];
return data_[i * width + j];
}
template<class T, Foam::label width>
......
......@@ -103,14 +103,14 @@ Foam::Ostream& Foam::operator<<
os << nl << DL.nextFree_ << nl;
if( DL.nextFree_ )
{
const long long blockSize = 1<<DL.shift_;
const label blockSize = 1<<DL.shift_;
long long currBlock(0);
long long currPos(0);
label currBlock(0);
label currPos(0);
while( currPos < DL.nextFree_ )
{
const long long bs =
const label bs =
Foam::min(DL.nextFree_ - currPos, blockSize);
os.write
......@@ -153,7 +153,7 @@ Foam::Istream& Foam::operator>>
if( firstToken.isLabel() )
{
const long long size = firstToken.labelToken();
const label size = firstToken.labelToken();
// Set list length to that read
DL.setSize(size);
......@@ -202,7 +202,7 @@ Foam::Istream& Foam::operator>>
if( listDelimiter == token::BEGIN_LIST )
{
for(register long long i=0;i<size;++i)
for(register label i=0;i<size;++i)
{
is >> DL[i];
......@@ -223,7 +223,7 @@ Foam::Istream& Foam::operator>>
"reading the single entry"
);
for(register long long i=0;i<size;++i)
for(register label i=0;i<size;++i)
{
DL[i] = element;
}
......@@ -234,14 +234,14 @@ Foam::Istream& Foam::operator>>
}
else
{
const long long blockSize = (1<<DL.shift_);
const label blockSize = (1<<DL.shift_);
long long currBlock(0);
long long currPos(0);
label currBlock(0);
label currPos(0);
while( currPos < size )
{
const long long bs = Foam::min(size - currPos, blockSize);
const label bs = Foam::min(size - currPos, blockSize);
is.read
(
......@@ -274,10 +274,15 @@ Foam::Istream& Foam::operator>>
template<class T, Foam::label Offset>
void Foam::LongList<T, Offset>::appendFromStream(Istream& is)
{
if( !is.good() )
Pout << "Drekec" << endl;
is.fatalCheck("appendFromStream(Istream& is)");
token firstToken(is);
Pout << "Read "<< firstToken.info() << endl;
is.fatalCheck
(
"appendFromStream(Istream& is) : reading first token"
......@@ -285,7 +290,7 @@ void Foam::LongList<T, Offset>::appendFromStream(Istream& is)
if( firstToken.isLabel() )
{
const long long size = firstToken.labelToken();
const label size = firstToken.labelToken();
if( size == 0 )
{
......@@ -293,7 +298,7 @@ void Foam::LongList<T, Offset>::appendFromStream(Istream& is)
return;
}
long long origSize(this->size());
label origSize(this->size());
// Set list length to that read
setSize(origSize+size);
......@@ -306,7 +311,7 @@ void Foam::LongList<T, Offset>::appendFromStream(Istream& is)
if( listDelimiter == token::BEGIN_LIST )
{
for(register long long i=0;i<size;++i)
for(register label i=0;i<size;++i)
{
is >> this->operator[](origSize);
++origSize;
......@@ -328,7 +333,7 @@ void Foam::LongList<T, Offset>::appendFromStream(Istream& is)
"reading the single entry"
);
for(register long long i=0;i<size;++i)
for(register label i=0;i<size;++i)
{
this->operator[](origSize) = element;
++origSize;
......@@ -346,15 +351,15 @@ void Foam::LongList<T, Offset>::appendFromStream(Istream& is)
forAll(buf, i)
this->operator[](origSize++) = buf[i];
/*const long long blockSize = 1<<shift_;
/*const label blockSize = 1<<shift_;
Info << "nextFree_ " << nextFree_ << endl;
//- append elements by reading binary block
while( origSize < nextFree_ )
{
const long long currBlock = origSize >> shift_;
const long long currPos = origSize & mask_;
const label currBlock = origSize >> shift_;
const label currPos = origSize & mask_;
Info << "Orig size " << origSize
<< nl << "currBlock " << currBlock
......@@ -362,7 +367,7 @@ void Foam::LongList<T, Offset>::appendFromStream(Istream& is)
T* data = &dataPtr_[currBlock][currPos];
long long bs = Foam::min(nextFree_-origSize, blockSize);
label bs = Foam::min(nextFree_-origSize, blockSize);
bs = Foam::min(blockSize - currPos, bs);
Info << "bs " << bs << endl;
......
......@@ -78,10 +78,10 @@ class LongList
{
// Private data
//- number of allocated elements
long long N_;
label N_;
//- number of elements in the list
long long nextFree_;
label nextFree_;
//- number of used blocks of data
label numBlocks_;
......@@ -101,13 +101,13 @@ class LongList
// Private member functions
//- check index
void checkIndex(const long long i) const;
void checkIndex(const label i) const;
//- initialize width and mask
void initializeParameters();
//- Allocate memory for the list
void allocateSize(const long long);
void allocateSize(const label);
//- delete all elements
void clearOut();
......@@ -120,10 +120,10 @@ public:
inline LongList();
//- Construct given size
explicit inline LongList(const long long size);
explicit inline LongList(const label size);
//- Construct to given size and initialize
explicit inline LongList(const long long size, const T& t);
explicit inline LongList(const label size, const T& t);
//- Copy contructor
inline LongList(const LongList<T, Offset>&);
......@@ -137,17 +137,17 @@ public:
// Access
//- Size of the active part of the list.
inline long long size() const;
inline label size() const;
//- Return the binary size in number of characters of the UList
// if the element is a primitive type
// i.e. contiguous<T>() == true
inline long long byteSize() const;
inline label byteSize() const;
// Edit
//- Reset size of List.
void setSize(const long long);
void setSize(const label);
//- Clear the list, i.e. set next free to zero.
// Allocated size does not change
......@@ -171,23 +171,23 @@ public:
//- check if the element is in the list (takes linear time)
inline bool contains(const T& e) const;
inline long long containsAtPosition(const T& e) const;
inline label containsAtPosition(const T& e) const;
//- Return and remove the element
inline T remove(const long long i);
inline T remove(const label i);
inline T removeLastElement();
//- get and set operators
inline const T& operator[](const long long i) const;
inline T& operator[](const long long i);
inline const T& operator[](const label i) const;
inline T& operator[](const label i);
//- Return non-const access to an element,
// resizing the list if necessary
inline T& operator()(const long long);
inline T& operator()(const label);
//- return a non-const access to an element,
// resize the list if necessary
inline T& newElmt(const long long);
inline T& newElmt(const label);
//- Assignment of all entries to the given value
inline void operator=(const T&);
......
......@@ -26,14 +26,14 @@ License
#include "contiguous.H"
template<class T, Foam::label Offset>
void Foam::LongList<T, Offset>::checkIndex(const long long i) const
void Foam::LongList<T, Offset>::checkIndex(const label i) const
{
if( (i < 0) || (i >= nextFree_) )
{
FatalErrorIn
(
"void Foam::LongList<T, label>::"
"checkIndex(const long long i) const"
"checkIndex(const label i) const"
) << "Index " << i << " is not in range " << 0
<< " and " << nextFree_ << abort(FatalError);
}
......@@ -57,13 +57,21 @@ void Foam::LongList<T, Offset>::initializeParameters()
}
template<class T, Foam::label Offset>
inline void Foam::LongList<T, Offset>::allocateSize(const long long s)
inline void Foam::LongList<T, Offset>::allocateSize(const label s)
{
if( s == 0 )
{
clearOut();
return;
}
else if( s < 0 )
{
FatalErrorIn
(
"template<class T, Foam::label Offset>\n"
"inline void Foam::LongList<T, Offset>::allocateSize(const label)"
) << "Negative size requested." << abort(FatalError);
}
const label numblock1 = ((s-1)>>shift_) + 1;
const label blockSize = 1<<shift_;
......@@ -136,7 +144,7 @@ inline Foam::LongList<T, Offset>::LongList()
//- Construct given size
template<class T, Foam::label Offset>
inline Foam::LongList<T, Offset>::LongList(const long long s)
inline Foam::LongList<T, Offset>::LongList(const label s)
:
N_(0),
nextFree_(0),
......@@ -153,7 +161,7 @@ inline Foam::LongList<T, Offset>::LongList(const long long s)
//- Construct given size
template<class T, Foam::label Offset>
inline Foam::LongList<T, Offset>::LongList(const long long s, const T& t)
inline Foam::LongList<T, Offset>::LongList(const label s, const T& t)
:
N_(0),
nextFree_(0),
......@@ -191,13 +199,13 @@ inline Foam::LongList<T, Offset>::~LongList()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class T, Foam::label Offset>
inline long long Foam::LongList<T, Offset>::size() const
inline Foam::label Foam::LongList<T, Offset>::size() const
{
return nextFree_;
}
template<class T, Foam::label Offset>
inline long long Foam::LongList<T, Offset>::byteSize() const
inline Foam::label Foam::LongList<T, Offset>::byteSize() const
{
if( !contiguous<T>() )
{
......@@ -211,7 +219,7 @@ inline long long Foam::LongList<T, Offset>::byteSize() const
}
template<class T, Foam::label Offset>
inline void Foam::LongList<T, Offset>::setSize(const long long i)
inline void Foam::LongList<T, Offset>::setSize(const label i)
{
allocateSize(i);
nextFree_ = i;
......@@ -273,7 +281,7 @@ inline void Foam::LongList<T, Offset>::appendIfNotIn(const T& e)
template<class T, Foam::label Offset>
inline bool Foam::LongList<T, Offset>::contains(const T& e) const
{
for(register long long i=0;i<nextFree_;++i)
for(register label i=0;i<nextFree_;++i)
if( (*this)[i] == e )
return true;
......@@ -281,12 +289,12 @@ inline bool Foam::LongList<T, Offset>::contains(const T& e) const
}
template<class T, Foam::label Offset>
inline long long Foam::LongList<T, Offset>::containsAtPosition
inline Foam::label Foam::LongList<T, Offset>::containsAtPosition
(
const T& e
) const
{
for(register long long i=0;i<nextFree_;++i)
for(register label i=0;i<nextFree_;++i)
if( (*this)[i] == e )
return i;
......@@ -294,7 +302,7 @@ inline long long Foam::LongList<T, Offset>::containsAtPosition
}
template<class T, Foam::label Offset>
inline T Foam::LongList<T, Offset>::remove(const long long i)
inline T Foam::LongList<T, Offset>::remove(const label i)
{
if( nextFree_ == 0 )
{
......@@ -330,7 +338,7 @@ inline T Foam::LongList<T, Offset>::removeLastElement()
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
template<class T, Foam::label Offset>
inline const T& Foam::LongList<T, Offset>::operator[](const long long i) const
inline const T& Foam::LongList<T, Offset>::operator[](const label i) const
{
#ifdef FULLDEBUG
checkIndex(i);
......@@ -340,7 +348,7 @@ inline const T& Foam::LongList<T, Offset>::operator[](const long long i) const
}
template<class T, Foam::label Offset>
inline T& Foam::LongList<T, Offset>::operator[](const long long i)
inline T& Foam::LongList<T, Offset>::operator[](const label i)
{
#ifdef FULLDEBUG
checkIndex(i);
......@@ -350,7 +358,7 @@ inline T& Foam::LongList<T, Offset>::operator[](const long long i)
}
template<class T, Foam::label Offset>
inline T& Foam::LongList<T, Offset>::operator()(const long long i)
inline T& Foam::LongList<T, Offset>::operator()(const label i)
{
if( i >= nextFree_ )
setSize(i+1);
......@@ -360,7 +368,7 @@ inline T& Foam::LongList<T, Offset>::operator()(const long long i)
template<class T, Foam::label Offset>
inline T& Foam::LongList<T, Offset>::newElmt(const long long i)
inline T& Foam::LongList<T, Offset>::newElmt(const label i)
{
return operator()(i);
}
......@@ -368,7 +376,7 @@ inline T& Foam::LongList<T, Offset>::newElmt(const long long i)
template<class T, Foam::label Offset>
inline void Foam::LongList<T, Offset>::operator=(const T& t)
{
for(register long long i=0;i<nextFree_;++i)
for(register label i=0;i<nextFree_;++i)
operator[](i) = t;
}
......@@ -376,7 +384,7 @@ template<class T, Foam::label Offset>
inline void Foam::LongList<T, Offset>::operator=(const LongList<T, Offset>& l)
{
setSize(l.size());
for(register long long i=0;i<l.nextFree_;++i)
for(register label i=0;i<l.nextFree_;++i)
operator[](i) = l[i];
}
......
......@@ -54,7 +54,7 @@ class rowElement
{
// Private data
//- starting element of the row
long long start_;
label start_;
//- number of elements in the row
label size_;
......@@ -67,7 +67,7 @@ class rowElement
size_()
{}
inline rowElement(const long long i, const label j)
inline rowElement(const label i, const label j)
:
start_(i),
size_(j)
......@@ -76,11 +76,11 @@ class rowElement
inline ~rowElement()
{}
inline long long start() const
inline label start() const
{
return start_;
}
inline long long& start()
inline label& start()
{
return start_;
}
......
......@@ -77,12 +77,12 @@ inline Foam::VRWGraph::VRWGraph
const label nColumnsInRow
)
:
data_(static_cast<long long>(nRows) * nColumnsInRow),
data_(nRows * nColumnsInRow),
rows_(nRows)
{
for(label rowI=0;rowI<nRows;++rowI)
{
rows_[rowI].start() = static_cast<long long>(rowI) * nColumnsInRow;
rows_[rowI].start() = rowI * nColumnsInRow;
rows_[rowI].size() = nColumnsInRow;
}
}
......@@ -94,12 +94,12 @@ inline Foam::VRWGraph::VRWGraph
const label t
)
:
data_(static_cast<long long>(nRows) * nColumnsInRow, t),
data_(nRows * nColumnsInRow, t),
rows_(nRows)
{
for(label rowI=0;rowI<nRows;++rowI)
{
rows_[rowI].start() = static_cast<long long>(rowI) * nColumnsInRow;
rows_[rowI].start() = rowI * nColumnsInRow;
rows_[rowI].size() = nColumnsInRow;
}
}
......@@ -158,11 +158,11 @@ void Foam::VRWGraph::setSizeAndColumnWidth
) << "This function should be used for empty graphs, only!"
<< exit(FatalError);
data_.setSize(static_cast<long long>(newNumRows) * rcWidth);
data_.setSize(newNumRows * rcWidth);
data_ = FREEENTRY;
rows_.setSize(newNumRows);
long long start(0);
label start(0);
for(label i=0;i<newNumRows;++i)
{
......@@ -181,7 +181,7 @@ inline void Foam::VRWGraph::setSizeAndRowSize(const ListType& l)
const label nRows = l.size();
rows_.setSize(nRows);
long long start(0);
label start(0);
for(label rowI=0;rowI<nRows;++rowI)
{
rows_[rowI].size() = l[rowI];
......@@ -214,7 +214,7 @@ inline void Foam::VRWGraph::setRowSize(const label rowI, const label newSize)
<< " and " << rows_.size() << abort(FatalError);
# endif
const long long start = rows_[rowI].start();
const label start = rows_[rowI].start();
if( start == INVALIDROW )
{
if( newSize > 0 )
......@@ -232,7 +232,7 @@ inline void Foam::VRWGraph::setRowSize(const label rowI, const label newSize)
for(label i=rows_[rowI].size();i<newSize;++i)
{
const long long j = start + i;
const label j = start + i;
if(
(j >= data_.size()) ||
(data_[j] != FREEENTRY) ||
......@@ -312,7 +312,7 @@ inline void Foam::VRWGraph::append(const label rowI, const label el)
}
else
{
const long long oldStart = re.start();
const label oldStart = re.start();
const label oldSize = re.size();
++re.size();
......@@ -357,7 +357,7 @@ inline void Foam::VRWGraph::setRow
)
{
this->setRowSize(rowI, l.size());
const long long start = rows_[rowI].start();
const label start = rows_[rowI].start();
const label size = l.size();
for(label elI=0;elI<size;++elI)
data_[start+elI] = l[elI];
......@@ -513,7 +513,7 @@ inline bool Foam::VRWGraph::contains
const label e
) const
{
const long long start = rows_[rowI].start();
const label start = rows_[rowI].start();
if( start == INVALIDROW )
return false;
const label size = rows_[rowI].size();
......@@ -531,7 +531,7 @@ inline Foam::label Foam::VRWGraph::containsAtPosition
const label e
) const
{
const long long start = rows_[rowI].start();
const label start = rows_[rowI].start();
if( start == INVALIDROW )
return -1;
......
......@@ -336,7 +336,7 @@ void VRWGraphSMPModifier::optimizeMemoryUsage()
# endif