Commit 322c67bd authored by Franjo's avatar Franjo
Browse files

Merge branch 'developmentPublicRepo' of...

Merge branch 'developmentPublicRepo' of https://git5.projectlocker.com/igui/cfMesh into developmentPublicRepo
parents a01e818c b73059f1
......@@ -32,8 +32,8 @@ void Foam::FRWGraph<T, width>::checkIndex(const label i, const label j) const
(
"void Foam::FRWGraph<T,width>::"
"checkIndex(const label i, const label j) const"
) << "Row index " << Foam::label(i)
<< " is not in range " << Foam::label(0)
) << "Row index " << i
<< " is not in range " << 0
<< " and " << nRows_ << abort(FatalError);
}
......@@ -41,9 +41,9 @@ void Foam::FRWGraph<T, width>::checkIndex(const label i, const label j) const
FatalErrorIn
(
"void Foam::FRWGraph<T,width>::"
"checkIndex(label const i) const"
) << "Column index " << Foam::label(j)
<< " is not in range " << Foam::label(0)
"checkIndex(const label i, const label j) const"
) << "Column index " << j
<< " is not in range " << 0
<< " and " << width << abort(FatalError);
}
......@@ -55,8 +55,7 @@ inline Foam::FRWGraph<T,width>::FRWGraph()
:
data_(),
nRows_(0)
{
}
{}
//- Construct given size
template<class T, Foam::label width>
......@@ -65,7 +64,7 @@ inline Foam::FRWGraph<T,width>::FRWGraph
const label s
)
:
data_(s * width),
data_(static_cast<long long>(s) * width),
nRows_(s)
{
}
......@@ -79,10 +78,9 @@ inline Foam::FRWGraph<T,width>::FRWGraph
const T& t
)
:
data_(s * width, t),
data_(static_cast<long long>(s) * width, t),
nRows_(s)
{
}
{}
template<class T, Foam::label width>
inline Foam::FRWGraph<T,width>::FRWGraph
......@@ -92,13 +90,11 @@ inline Foam::FRWGraph<T,width>::FRWGraph
:
data_(ol.data_),
nRows_(ol.nRows_)
{
}
{}
template<class T, Foam::label width>
inline Foam::FRWGraph<T,width>::~FRWGraph()
{
}
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
......@@ -118,7 +114,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(i * width);
data_.setSize(static_cast<long long>(i) * width);
nRows_ = i;
}
......@@ -159,7 +155,7 @@ inline bool Foam::FRWGraph<T,width>::contains
const T& e
) const
{
const label start = rowI * width;
const long long start = static_cast<long long>(rowI) * width;
for(register label i=0;i<width;++i)
if( data_[start+i] == e )
return true;
......@@ -174,7 +170,7 @@ inline Foam::label Foam::FRWGraph<T,width>::containsAtPosition
const T& e
) const
{
const label start = rowI * width;
const long long start = static_cast<long long>(rowI) * width;
for(register label i=0;i<width;++i)
if( data_[start+i] == e )
return i;
......@@ -194,7 +190,7 @@ inline const T& Foam::FRWGraph<T,width>::operator()
checkIndex(i, j);
#endif
return data_[i * width + j];
return data_[static_cast<long long>(i) * width + j];
}
template<class T, Foam::label width>
......@@ -207,7 +203,7 @@ inline T& Foam::FRWGraph<T,width>::operator()
checkIndex(i, j);
#endif
return data_[i * width + j];
return data_[static_cast<long long>(i) * width + j];
}
template<class T, Foam::label width>
......@@ -217,6 +213,7 @@ inline void Foam::FRWGraph<T,width>::operator=
)
{
data_ = l.data_;
nRows_ = l.nRows_;
}
......
......@@ -103,14 +103,15 @@ Foam::Ostream& Foam::operator<<
os << nl << DL.nextFree_ << nl;
if( DL.nextFree_ )
{
const label blockSize = 1<<DL.shift_;
const long long blockSize = 1<<DL.shift_;
label currBlock(0);
label currPos(0);
long long currBlock(0);
long long currPos(0);
while( currPos < DL.nextFree_ )
{
const label bs = Foam::min(DL.nextFree_ - currPos, blockSize);
const long long bs =
Foam::min(DL.nextFree_ - currPos, blockSize);
os.write
(
......@@ -152,7 +153,7 @@ Foam::Istream& Foam::operator>>
if( firstToken.isLabel() )
{
const label size = firstToken.labelToken();
const long long size = firstToken.labelToken();
// Set list length to that read
DL.setSize(size);
......@@ -201,7 +202,7 @@ Foam::Istream& Foam::operator>>
if( listDelimiter == token::BEGIN_LIST )
{
for(register label i=0;i<size;++i)
for(register long long i=0;i<size;++i)
{
is >> DL[i];
......@@ -222,7 +223,7 @@ Foam::Istream& Foam::operator>>
"reading the single entry"
);
for(register label i=0;i<size;++i)
for(register long long i=0;i<size;++i)
{
DL[i] = element;
}
......@@ -233,14 +234,14 @@ Foam::Istream& Foam::operator>>
}
else
{
const label blockSize = (1<<DL.shift_);
const long long blockSize = (1<<DL.shift_);
label currBlock(0);
label currPos(0);
long long currBlock(0);
long long currPos(0);
while( currPos < size )
{
const label bs = Foam::min(size - currPos, blockSize);
const long long bs = Foam::min(size - currPos, blockSize);
is.read
(
......@@ -284,7 +285,7 @@ void Foam::LongList<T, Offset>::appendFromStream(Istream& is)
if( firstToken.isLabel() )
{
const label size = firstToken.labelToken();
const long long size = firstToken.labelToken();
if( size == 0 )
{
......@@ -292,7 +293,7 @@ void Foam::LongList<T, Offset>::appendFromStream(Istream& is)
return;
}
label origSize(this->size());
long long origSize(this->size());
// Set list length to that read
setSize(origSize+size);
......@@ -305,7 +306,7 @@ void Foam::LongList<T, Offset>::appendFromStream(Istream& is)
if( listDelimiter == token::BEGIN_LIST )
{
for(register label i=0;i<size;++i)
for(register long long i=0;i<size;++i)
{
is >> this->operator[](origSize);
++origSize;
......@@ -327,7 +328,7 @@ void Foam::LongList<T, Offset>::appendFromStream(Istream& is)
"reading the single entry"
);
for(register label i=0;i<size;++i)
for(register long long i=0;i<size;++i)
{
this->operator[](origSize) = element;
++origSize;
......@@ -345,15 +346,15 @@ void Foam::LongList<T, Offset>::appendFromStream(Istream& is)
forAll(buf, i)
this->operator[](origSize++) = buf[i];
/*const label blockSize = 1<<shift_;
/*const long long blockSize = 1<<shift_;
Info << "nextFree_ " << nextFree_ << endl;
//- append elements by reading binary block
while( origSize < nextFree_ )
{
const label currBlock = origSize >> shift_;
const label currPos = origSize & mask_;
const long long currBlock = origSize >> shift_;
const long long currPos = origSize & mask_;
Info << "Orig size " << origSize
<< nl << "currBlock " << currBlock
......@@ -361,7 +362,7 @@ void Foam::LongList<T, Offset>::appendFromStream(Istream& is)
T* data = &dataPtr_[currBlock][currPos];
label bs = Foam::min(nextFree_-origSize, blockSize);
long long bs = Foam::min(nextFree_-origSize, blockSize);
bs = Foam::min(blockSize - currPos, bs);
Info << "bs " << bs << endl;
......
......@@ -41,6 +41,7 @@ SourceFiles
#define LongList_H
#include "label.H"
#include "longLong.H"
#include "bool.H"
#include "IOstreams.H"
#include "error.H"
......@@ -77,40 +78,40 @@ class LongList
{
// Private data
//- number of allocated elements
label N_;
long long N_;
//- number of elements in the list
label nextFree_;
long long nextFree_;
//- number of used blocks of data
label numBlocks_;
//- maximum number of blocks that can be allocated
//- without reallocating the list containing pointers
//- to the chunks of data
label numAllocatedBlocks_;
//- size of blocks is calculated by powers of 2
//- and therefore the access can be done using shift and mask
label shift_;
label mask_;
//- array of pointers to the blocks of data, each of the size WIDTH
T** dataPtr_;
// Private member functions
//- check index
void checkIndex(label const i) const;
void checkIndex(const long long i) const;
//- initialize width and mask
void initializeParameters();
//- Allocate memory for the list
void allocateSize(const label);
void allocateSize(const long long);
//- delete all elements
void clearOut();
public:
// Constructors
......@@ -119,10 +120,10 @@ public:
inline LongList();
//- Construct given size
explicit inline LongList(const label size);
explicit inline LongList(const long long size);
//- Construct to given size and initialize
explicit inline LongList(const label size, const T& t);
explicit inline LongList(const long long size, const T& t);
//- Copy contructor
inline LongList(const LongList<T, Offset>&);
......@@ -136,17 +137,17 @@ public:
// Access
//- Size of the active part of the list.
inline label size() const;
inline long long size() const;
//- Return the binary size in number of characters of the UList
// if the element is a primitive type
// if the element is a primitive type
// i.e. contiguous<T>() == true
inline label byteSize() const;
inline long long byteSize() const;
// Edit
//- Reset size of List.
void setSize(const label);
void setSize(const long long);
//- Clear the list, i.e. set next free to zero.
// Allocated size does not change
......@@ -154,7 +155,7 @@ public:
//- Shrink the list to the number of elements used
inline LongList<T, Offset>& shrink();
//- transfer the list from another one without allocating it
inline void transfer(LongList<T, Offset>&);
......@@ -163,34 +164,34 @@ public:
//- Append an element at the end of the list
inline void append(const T& e);
//- Append an element at the end of the list if it is not yet
//- present in the list (takes linear time)
inline void appendIfNotIn(const T& e);
//- check if the element is in the list (takes linear time)
inline bool contains(const T& e) const;
inline label containsAtPosition(const T& e) const;
inline long long containsAtPosition(const T& e) const;
//- Return and remove the element
inline T remove(const label i);
inline T remove(const long long i);
inline T removeLastElement();
//- get and set operators
inline const T& operator[](const label i) const;
inline T& operator[](const label i);
inline const T& operator[](const long long i) const;
inline T& operator[](const long long i);
//- Return non-const access to an element,
// resizing the list if necessary
inline T& operator()(const label);
inline T& operator()(const long long);
//- return a non-const access to an element,
// resize the list if necessary
inline T& newElmt(const label);
inline T& newElmt(const long long);
//- Assignment of all entries to the given value
inline void operator=(const T&);
//- Assignment operator
inline void operator=(const LongList<T, Offset>&);
......@@ -198,7 +199,7 @@ public:
// IOstream operators
//- Read from stream and append to the current content
void appendFromStream(Istream&);
//- Write as a dictionary entry.
void writeEntry(Ostream& os) const;
......
......@@ -26,16 +26,16 @@ License
#include "contiguous.H"
template<class T, Foam::label Offset>
void Foam::LongList<T, Offset>::checkIndex(const label i) const
void Foam::LongList<T, Offset>::checkIndex(const long long i) const
{
if( (i < 0) || (i >= nextFree_) )
{
FatalErrorIn
(
"void Foam::LongList<T, label, Offset>::"
"checkIndex(const label i) const"
) << "Index " << Foam::label(i) << " is not in range " << Foam::label(0)
<< " and " << Foam::label(nextFree_) << abort(FatalError);
"void Foam::LongList<T, label>::"
"checkIndex(const long long i) const"
) << "Index " << i << " is not in range " << 0
<< " and " << nextFree_ << abort(FatalError);
}
}
......@@ -44,30 +44,30 @@ void Foam::LongList<T, Offset>::initializeParameters()
{
unsigned int t = sizeof(T);
label it(0);
while( t > 1 )
{
t >>= 1;
++it;
}
shift_ = Foam::max(10, Offset - it);
mask_ = 1<<shift_;
mask_ -= 1;
}
template<class T, Foam::label Offset>
inline void Foam::LongList<T, Offset>::allocateSize(const label s)
inline void Foam::LongList<T, Offset>::allocateSize(const long long s)
{
if( s == 0 )
{
clearOut();
return;
}
const label numblock1 = ((s-1)>>shift_) + 1;
const label blockSize = 1<<shift_;
if( numblock1 < numBlocks_ )
{
for(register label i=numblock1;i<numBlocks_;++i)
......@@ -81,20 +81,20 @@ inline void Foam::LongList<T, Offset>::allocateSize(const label s)
{
numAllocatedBlocks_ += 64;
} while( numblock1 > numAllocatedBlocks_ );
T** dataptr1 = new T*[numAllocatedBlocks_];
for(register label i=0;i<numBlocks_;++i)
dataptr1[i] = dataPtr_[i];
if( dataPtr_ )
delete [] dataPtr_;
dataPtr_ = dataptr1;
}
for(register label i=numBlocks_;i<numblock1;++i)
dataPtr_[i] = new T[blockSize];
}
numBlocks_ = numblock1;
N_ = numBlocks_ * blockSize;
}
......@@ -104,13 +104,13 @@ void Foam::LongList<T, Offset>::clearOut()
{
for(register label i=0;i<numBlocks_;++i)
delete [] dataPtr_[i];
if( dataPtr_ )
{
delete [] dataPtr_;
dataPtr_ = NULL;
}
N_ = 0;
numBlocks_ = 0;
numAllocatedBlocks_ = 0;
......@@ -136,7 +136,7 @@ inline Foam::LongList<T, Offset>::LongList()
//- Construct given size
template<class T, Foam::label Offset>
inline Foam::LongList<T, Offset>::LongList(const label s)
inline Foam::LongList<T, Offset>::LongList(const long long s)
:
N_(0),
nextFree_(0),
......@@ -153,7 +153,7 @@ inline Foam::LongList<T, Offset>::LongList(const label s)
//- Construct given size
template<class T, Foam::label Offset>
inline Foam::LongList<T, Offset>::LongList(const label s, const T& t)
inline Foam::LongList<T, Offset>::LongList(const long long s, const T& t)
:
N_(0),
nextFree_(0),
......@@ -191,13 +191,13 @@ inline Foam::LongList<T, Offset>::~LongList()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class T, Foam::label Offset>
inline Foam::label Foam::LongList<T, Offset>::size() const
inline long long Foam::LongList<T, Offset>::size() const
{
return nextFree_;
}
template<class T, Foam::label Offset>
inline Foam::label Foam::LongList<T, Offset>::byteSize() const
inline long long Foam::LongList<T, Offset>::byteSize() const
{
if( !contiguous<T>() )
{
......@@ -211,7 +211,7 @@ inline Foam::label Foam::LongList<T, Offset>::byteSize() const
}
template<class T, Foam::label Offset>
inline void Foam::LongList<T, Offset>::setSize(const label i)
inline void Foam::LongList<T, Offset>::setSize(const long long i)
{
allocateSize(i);
nextFree_ = i;
......@@ -243,7 +243,7 @@ inline void Foam::LongList<T, Offset>::transfer(LongList<T, Offset>& ol)
numAllocatedBlocks_ = ol.numAllocatedBlocks_;
shift_ = ol.shift_;
mask_ = ol.mask_;
ol.dataPtr_ = NULL;
ol.N_ = 0;
ol.nextFree_ = 0;
......@@ -259,7 +259,7 @@ inline void Foam::LongList<T, Offset>::append(const T& e)
{
allocateSize(nextFree_+1);
}
operator[](nextFree_++) = e;
}
......@@ -273,28 +273,28 @@ 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 label i=0;i<nextFree_;++i)
for(register long long i=0;i<nextFree_;++i)
if( (*this)[i] == e )
return true;
return false;
}
template<class T, Foam::label Offset>
inline Foam::label Foam::LongList<T, Offset>::containsAtPosition
inline long long Foam::LongList<T, Offset>::containsAtPosition
(
const T& e
) const
{
for(register label i=0;i<nextFree_;++i)
for(register long long i=0;i<nextFree_;++i)
if( (*this)[i] == e )
return i;
return -1;
}
template<class T, Foam::label Offset>
inline T Foam::LongList<T, Offset>::remove(const label i)
inline T Foam::LongList<T, Offset>::remove(const long long i)
{
if( nextFree_ == 0 )
{
......@@ -303,7 +303,7 @@ inline T Foam::LongList<T, Offset>::remove(const label i)
"void Foam::LongList<T, Offset>::remove()"
) << "List is empty" << abort(FatalError);
}
T el = operator[](i);
operator[](i) = operator[](nextFree_-1);
--nextFree_;
......@@ -320,7 +320,7 @@ inline T Foam::LongList<T, Offset>::removeLastElement()
"void Foam::LongList<T, Offset>::remove()"
) << "List is empty" << abort(FatalError);