Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Development
openfoam
Commits
55d4fb2e
Commit
55d4fb2e
authored
Jan 29, 2009
by
Mark Olesen
Browse files
PackedList with unsigned template parameter
parent
6ac84bf1
Changes
5
Hide whitespace changes
Inline
Side-by-side
src/OpenFOAM/containers/Lists/PackedList/PackedList.C
View file @
55d4fb2e
...
...
@@ -28,7 +28,7 @@ License
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template
<
int
nBits
>
template
<
unsigned
nBits
>
Foam
::
PackedList
<
nBits
>::
PackedList
(
const
label
size
,
const
unsigned
int
val
)
:
StorageList
(
packedLength
(
size
),
0u
),
...
...
@@ -38,7 +38,7 @@ Foam::PackedList<nBits>::PackedList(const label size, const unsigned int val)
}
template
<
int
nBits
>
template
<
unsigned
nBits
>
Foam
::
PackedList
<
nBits
>::
PackedList
(
const
UList
<
label
>&
lst
)
:
StorageList
(
packedLength
(
lst
.
size
()),
0u
),
...
...
@@ -76,7 +76,7 @@ Foam::PackedList<nBits>::PackedList(const UList<label>& lst)
#endif
template
<
int
nBits
>
template
<
unsigned
nBits
>
unsigned
int
Foam
::
PackedList
<
nBits
>::
count
()
const
{
register
unsigned
int
c
=
0
;
...
...
@@ -110,7 +110,7 @@ unsigned int Foam::PackedList<nBits>::count() const
}
template
<
int
nBits
>
template
<
unsigned
nBits
>
bool
Foam
::
PackedList
<
nBits
>::
trim
()
{
if
(
!
size_
)
...
...
@@ -162,7 +162,7 @@ bool Foam::PackedList<nBits>::trim()
}
template
<
int
nBits
>
template
<
unsigned
nBits
>
Foam
::
labelList
Foam
::
PackedList
<
nBits
>::
values
()
const
{
labelList
elems
(
size
());
...
...
@@ -175,10 +175,10 @@ Foam::labelList Foam::PackedList<nBits>::values() const
}
template
<
int
nBits
>
template
<
unsigned
nBits
>
Foam
::
Ostream
&
Foam
::
PackedList
<
nBits
>::
iteratorBase
::
print
(
Ostream
&
os
)
const
{
os
<<
"iterator<"
<<
nBits
<<
"> ["
os
<<
"iterator<"
<<
label
(
nBits
)
<<
"> ["
<<
(
index_
*
packing
()
+
offset_
)
<<
"]"
<<
" index:"
<<
index_
<<
" offset:"
<<
offset_
<<
" value:"
<<
unsigned
(
*
this
)
...
...
@@ -188,10 +188,10 @@ Foam::Ostream& Foam::PackedList<nBits>::iteratorBase::print(Ostream& os) const
}
template
<
int
nBits
>
template
<
unsigned
nBits
>
Foam
::
Ostream
&
Foam
::
PackedList
<
nBits
>::
print
(
Ostream
&
os
)
const
{
os
<<
"PackedList<"
<<
nBits
<<
">"
os
<<
"PackedList<"
<<
label
(
nBits
)
<<
">"
<<
" max_value:"
<<
max_value
()
<<
" packing:"
<<
packing
()
<<
nl
<<
"values: "
<<
size
()
<<
"/"
<<
capacity
()
<<
"( "
;
...
...
@@ -255,7 +255,7 @@ Foam::Ostream& Foam::PackedList<nBits>::print(Ostream& os) const
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
template
<
int
nBits
>
template
<
unsigned
nBits
>
void
Foam
::
PackedList
<
nBits
>::
operator
=
(
const
PackedList
<
nBits
>&
lst
)
{
setCapacity
(
lst
.
size
());
...
...
@@ -263,7 +263,7 @@ void Foam::PackedList<nBits>::operator=(const PackedList<nBits>& lst)
}
template
<
int
nBits
>
template
<
unsigned
nBits
>
void
Foam
::
PackedList
<
nBits
>::
operator
=
(
const
UList
<
label
>&
lst
)
{
setCapacity
(
lst
.
size
());
...
...
@@ -277,7 +277,7 @@ void Foam::PackedList<nBits>::operator=(const UList<label>& lst)
// * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * //
//template<
int
nBits>
//template<
unsigned
nBits>
//Foam::Ostream& ::Foam::operator<<(Ostream& os, const PackedList<nBits>& lst)
//{
// os << lst();
...
...
src/OpenFOAM/containers/Lists/PackedList/PackedList.H
View file @
55d4fb2e
...
...
@@ -86,9 +86,9 @@ namespace Foam
{
// Forward declaration of friend functions and operators
template
<
int
nBits
>
class
PackedList
;
template
<
unsigned
nBits
>
class
PackedList
;
// template<
int
nBits>
// template<
unsigned
nBits>
// Ostream& operator<<(Ostream&, const PackedList<nBits>&);
...
...
@@ -102,7 +102,7 @@ TemplateName(PackedList);
Class PackedList Declaration
\*---------------------------------------------------------------------------*/
template
<
int
nBits
=
1
>
template
<
unsigned
nBits
=
1
>
class
PackedList
:
private
List
<
unsigned
int
>
...
...
src/OpenFOAM/containers/Lists/PackedList/PackedListI.H
View file @
55d4fb2e
...
...
@@ -30,42 +30,42 @@ License
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template
<
int
nBits
>
template
<
unsigned
nBits
>
inline
unsigned
int
Foam
::
PackedList
<
nBits
>::
max_bits
()
{
return
sizeof
(
StorageType
)
*
CHAR_BIT
-
1
;
}
template
<
int
nBits
>
template
<
unsigned
nBits
>
inline
unsigned
int
Foam
::
PackedList
<
nBits
>::
max_value
()
{
return
(
1
<<
nBits
)
-
1
;
}
template
<
int
nBits
>
template
<
unsigned
nBits
>
inline
unsigned
int
Foam
::
PackedList
<
nBits
>::
packing
()
{
return
sizeof
(
StorageType
)
*
CHAR_BIT
/
nBits
;
}
template
<
int
nBits
>
template
<
unsigned
nBits
>
inline
unsigned
int
Foam
::
PackedList
<
nBits
>::
maskLower
(
unsigned
offset
)
{
return
(
1
<<
(
nBits
*
offset
))
-
1
;
}
template
<
int
nBits
>
template
<
unsigned
nBits
>
inline
Foam
::
label
Foam
::
PackedList
<
nBits
>::
packedLength
(
const
label
nElem
)
{
return
(
nElem
+
packing
()
-
1
)
/
packing
();
}
template
<
int
nBits
>
template
<
unsigned
nBits
>
inline
void
Foam
::
PackedList
<
nBits
>::
checkIndex
(
const
label
i
)
const
{
if
(
!
size_
)
...
...
@@ -85,7 +85,7 @@ inline void Foam::PackedList<nBits>::checkIndex(const label i) const
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template
<
int
nBits
>
template
<
unsigned
nBits
>
inline
Foam
::
PackedList
<
nBits
>::
PackedList
()
:
StorageList
(),
...
...
@@ -93,7 +93,7 @@ inline Foam::PackedList<nBits>::PackedList()
{}
template
<
int
nBits
>
template
<
unsigned
nBits
>
inline
Foam
::
PackedList
<
nBits
>::
PackedList
(
const
label
size
)
:
StorageList
(
packedLength
(
size
),
0u
),
...
...
@@ -101,7 +101,7 @@ inline Foam::PackedList<nBits>::PackedList(const label size)
{}
template
<
int
nBits
>
template
<
unsigned
nBits
>
inline
Foam
::
PackedList
<
nBits
>::
PackedList
(
const
PackedList
<
nBits
>&
lst
)
:
StorageList
(
lst
),
...
...
@@ -109,14 +109,14 @@ inline Foam::PackedList<nBits>::PackedList(const PackedList<nBits>& lst)
{}
template
<
int
nBits
>
template
<
unsigned
nBits
>
inline
Foam
::
PackedList
<
nBits
>::
PackedList
(
const
Xfer
<
PackedList
<
nBits
>
>&
lst
)
{
transfer
(
lst
());
}
template
<
int
nBits
>
template
<
unsigned
nBits
>
inline
Foam
::
autoPtr
<
Foam
::
PackedList
<
nBits
>
>
Foam
::
PackedList
<
nBits
>::
clone
()
const
{
...
...
@@ -128,7 +128,7 @@ Foam::PackedList<nBits>::clone() const
// iteratorBase
template
<
int
nBits
>
template
<
unsigned
nBits
>
inline
Foam
::
PackedList
<
nBits
>::
iteratorBase
::
iteratorBase
()
:
list_
(
0
),
...
...
@@ -137,7 +137,7 @@ inline Foam::PackedList<nBits>::iteratorBase::iteratorBase()
{}
template
<
int
nBits
>
template
<
unsigned
nBits
>
inline
Foam
::
PackedList
<
nBits
>::
iteratorBase
::
iteratorBase
(
const
iteratorBase
&
iter
...
...
@@ -149,7 +149,7 @@ inline Foam::PackedList<nBits>::iteratorBase::iteratorBase
{}
template
<
int
nBits
>
template
<
unsigned
nBits
>
inline
Foam
::
PackedList
<
nBits
>::
iteratorBase
::
iteratorBase
(
const
PackedList
<
nBits
>*
lst
,
...
...
@@ -162,7 +162,7 @@ inline Foam::PackedList<nBits>::iteratorBase::iteratorBase
{}
template
<
int
nBits
>
template
<
unsigned
nBits
>
inline
unsigned
int
Foam
::
PackedList
<
nBits
>::
iteratorBase
::
get
()
const
{
...
...
@@ -171,7 +171,7 @@ Foam::PackedList<nBits>::iteratorBase::get() const
}
template
<
int
nBits
>
template
<
unsigned
nBits
>
inline
bool
Foam
::
PackedList
<
nBits
>::
iteratorBase
::
set
(
const
unsigned
int
val
)
{
...
...
@@ -204,7 +204,7 @@ w << " out-of-range 0 ... " << label(max_value())
template
<
int
nBits
>
template
<
unsigned
nBits
>
inline
void
Foam
::
PackedList
<
nBits
>::
iteratorBase
::
incr
()
{
...
...
@@ -217,7 +217,7 @@ Foam::PackedList<nBits>::iteratorBase::incr()
}
template
<
int
nBits
>
template
<
unsigned
nBits
>
inline
void
Foam
::
PackedList
<
nBits
>::
iteratorBase
::
decr
()
{
...
...
@@ -230,7 +230,7 @@ Foam::PackedList<nBits>::iteratorBase::decr()
}
template
<
int
nBits
>
template
<
unsigned
nBits
>
inline
void
Foam
::
PackedList
<
nBits
>::
iteratorBase
::
seek
(
...
...
@@ -245,7 +245,7 @@ Foam::PackedList<nBits>::iteratorBase::seek
}
template
<
int
nBits
>
template
<
unsigned
nBits
>
inline
bool
Foam
::
PackedList
<
nBits
>::
iteratorBase
::
valid
()
const
{
...
...
@@ -254,7 +254,7 @@ Foam::PackedList<nBits>::iteratorBase::valid() const
}
template
<
int
nBits
>
template
<
unsigned
nBits
>
inline
bool
Foam
::
PackedList
<
nBits
>::
iteratorBase
::
validate
()
{
...
...
@@ -276,7 +276,7 @@ Foam::PackedList<nBits>::iteratorBase::validate()
}
template
<
int
nBits
>
template
<
unsigned
nBits
>
inline
bool
Foam
::
PackedList
<
nBits
>::
iteratorBase
::
operator
==
(
const
iteratorBase
&
iter
...
...
@@ -286,7 +286,7 @@ inline bool Foam::PackedList<nBits>::iteratorBase::operator==
}
template
<
int
nBits
>
template
<
unsigned
nBits
>
inline
bool
Foam
::
PackedList
<
nBits
>::
iteratorBase
::
operator
!=
(
const
iteratorBase
&
iter
...
...
@@ -296,7 +296,7 @@ inline bool Foam::PackedList<nBits>::iteratorBase::operator!=
}
template
<
int
nBits
>
template
<
unsigned
nBits
>
inline
unsigned
int
Foam
::
PackedList
<
nBits
>::
iteratorBase
::
operator
=
(
const
iteratorBase
&
iter
)
{
...
...
@@ -306,7 +306,7 @@ Foam::PackedList<nBits>::iteratorBase::operator=(const iteratorBase& iter)
}
template
<
int
nBits
>
template
<
unsigned
nBits
>
inline
unsigned
int
Foam
::
PackedList
<
nBits
>::
iteratorBase
::
operator
=
(
const
unsigned
int
val
)
{
...
...
@@ -324,7 +324,7 @@ Foam::PackedList<nBits>::iteratorBase::operator=(const unsigned int val)
}
template
<
int
nBits
>
template
<
unsigned
nBits
>
inline
Foam
::
PackedList
<
nBits
>::
iteratorBase
::
operator
unsigned
int
()
const
{
...
...
@@ -343,21 +343,21 @@ unsigned int () const
// const_iterator, iterator
template
<
int
nBits
>
template
<
unsigned
nBits
>
inline
Foam
::
PackedList
<
nBits
>::
iterator
::
iterator
()
:
iteratorBase
()
{}
template
<
int
nBits
>
template
<
unsigned
nBits
>
inline
Foam
::
PackedList
<
nBits
>::
const_iterator
::
const_iterator
()
:
iteratorBase
()
{}
template
<
int
nBits
>
template
<
unsigned
nBits
>
inline
Foam
::
PackedList
<
nBits
>::
iterator
::
iterator
(
const
iteratorBase
&
iter
...
...
@@ -369,7 +369,7 @@ inline Foam::PackedList<nBits>::iterator::iterator
}
template
<
int
nBits
>
template
<
unsigned
nBits
>
inline
Foam
::
PackedList
<
nBits
>::
const_iterator
::
const_iterator
(
const
iteratorBase
&
iter
...
...
@@ -381,7 +381,7 @@ inline Foam::PackedList<nBits>::const_iterator::const_iterator
}
template
<
int
nBits
>
template
<
unsigned
nBits
>
inline
Foam
::
PackedList
<
nBits
>::
iterator
::
iterator
(
const
PackedList
<
nBits
>*
lst
,
...
...
@@ -392,7 +392,7 @@ inline Foam::PackedList<nBits>::iterator::iterator
{}
template
<
int
nBits
>
template
<
unsigned
nBits
>
inline
Foam
::
PackedList
<
nBits
>::
const_iterator
::
const_iterator
(
const
PackedList
<
nBits
>*
lst
,
...
...
@@ -403,7 +403,7 @@ inline Foam::PackedList<nBits>::const_iterator::const_iterator
{}
template
<
int
nBits
>
template
<
unsigned
nBits
>
inline
Foam
::
PackedList
<
nBits
>::
const_iterator
::
const_iterator
(
const
iterator
&
iter
...
...
@@ -413,7 +413,7 @@ inline Foam::PackedList<nBits>::const_iterator::const_iterator
{}
template
<
int
nBits
>
template
<
unsigned
nBits
>
inline
typename
Foam
::
PackedList
<
nBits
>::
iterator
&
Foam
::
PackedList
<
nBits
>::
iterator
::
operator
=
(
const
iteratorBase
&
iter
)
{
...
...
@@ -422,7 +422,7 @@ Foam::PackedList<nBits>::iterator::operator=(const iteratorBase& iter)
}
template
<
int
nBits
>
template
<
unsigned
nBits
>
inline
typename
Foam
::
PackedList
<
nBits
>::
const_iterator
&
Foam
::
PackedList
<
nBits
>::
const_iterator
::
operator
=
(
const
iteratorBase
&
iter
)
{
...
...
@@ -431,7 +431,7 @@ Foam::PackedList<nBits>::const_iterator::operator=(const iteratorBase& iter)
}
template
<
int
nBits
>
template
<
unsigned
nBits
>
inline
typename
Foam
::
PackedList
<
nBits
>::
iterator
&
Foam
::
PackedList
<
nBits
>::
iterator
::
operator
++
()
{
...
...
@@ -440,7 +440,7 @@ Foam::PackedList<nBits>::iterator::operator++()
}
template
<
int
nBits
>
template
<
unsigned
nBits
>
inline
typename
Foam
::
PackedList
<
nBits
>::
const_iterator
&
Foam
::
PackedList
<
nBits
>::
const_iterator
::
operator
++
()
{
...
...
@@ -449,7 +449,7 @@ Foam::PackedList<nBits>::const_iterator::operator++()
}
template
<
int
nBits
>
template
<
unsigned
nBits
>
inline
typename
Foam
::
PackedList
<
nBits
>::
iterator
Foam
::
PackedList
<
nBits
>::
iterator
::
operator
++
(
int
)
{
...
...
@@ -459,7 +459,7 @@ Foam::PackedList<nBits>::iterator::operator++(int)
}
template
<
int
nBits
>
template
<
unsigned
nBits
>
inline
typename
Foam
::
PackedList
<
nBits
>::
const_iterator
Foam
::
PackedList
<
nBits
>::
const_iterator
::
operator
++
(
int
)
{
...
...
@@ -469,7 +469,7 @@ Foam::PackedList<nBits>::const_iterator::operator++(int)
}
template
<
int
nBits
>
template
<
unsigned
nBits
>
inline
typename
Foam
::
PackedList
<
nBits
>::
iterator
&
Foam
::
PackedList
<
nBits
>::
iterator
::
operator
--
()
{
...
...
@@ -478,7 +478,7 @@ Foam::PackedList<nBits>::iterator::operator--()
}
template
<
int
nBits
>
template
<
unsigned
nBits
>
inline
typename
Foam
::
PackedList
<
nBits
>::
const_iterator
&
Foam
::
PackedList
<
nBits
>::
const_iterator
::
operator
--
()
{
...
...
@@ -487,7 +487,7 @@ Foam::PackedList<nBits>::const_iterator::operator--()
}
template
<
int
nBits
>
template
<
unsigned
nBits
>
inline
typename
Foam
::
PackedList
<
nBits
>::
iterator
Foam
::
PackedList
<
nBits
>::
iterator
::
operator
--
(
int
)
{
...
...
@@ -497,7 +497,7 @@ Foam::PackedList<nBits>::iterator::operator--(int)
}
template
<
int
nBits
>
template
<
unsigned
nBits
>
inline
typename
Foam
::
PackedList
<
nBits
>::
const_iterator
Foam
::
PackedList
<
nBits
>::
const_iterator
::
operator
--
(
int
)
{
...
...
@@ -507,7 +507,7 @@ Foam::PackedList<nBits>::const_iterator::operator--(int)
}
template
<
int
nBits
>
template
<
unsigned
nBits
>
inline
typename
Foam
::
PackedList
<
nBits
>::
iteratorBase
&
Foam
::
PackedList
<
nBits
>::
iterator
::
operator
*
()
{
...
...
@@ -515,7 +515,7 @@ Foam::PackedList<nBits>::iterator::operator*()
}
template
<
int
nBits
>
template
<
unsigned
nBits
>
inline
typename
Foam
::
PackedList
<
nBits
>::
iteratorBase
&
Foam
::
PackedList
<
nBits
>::
iterator
::
operator
()()
{
...
...
@@ -523,7 +523,7 @@ Foam::PackedList<nBits>::iterator::operator()()
}
template
<
int
nBits
>
template
<
unsigned
nBits
>
inline
unsigned
int
Foam
::
PackedList
<
nBits
>::
const_iterator
::
operator
*
()
const
{
...
...
@@ -531,7 +531,7 @@ Foam::PackedList<nBits>::const_iterator::operator*() const
}
template
<
int
nBits
>
template
<
unsigned
nBits
>
inline
unsigned
int
Foam
::
PackedList
<
nBits
>::
const_iterator
::
operator
()()
const
{
...
...
@@ -539,7 +539,7 @@ Foam::PackedList<nBits>::const_iterator::operator()() const
}
template
<
int
nBits
>
template
<
unsigned
nBits
>
inline
typename
Foam
::
PackedList
<
nBits
>::
iterator
Foam
::
PackedList
<
nBits
>::
begin
()
{
...
...
@@ -547,7 +547,7 @@ Foam::PackedList<nBits>::begin()
}
template
<
int
nBits
>
template
<
unsigned
nBits
>
inline
typename
Foam
::
PackedList
<
nBits
>::
const_iterator
Foam
::
PackedList
<
nBits
>::
begin
()
const
{
...
...
@@ -555,7 +555,7 @@ Foam::PackedList<nBits>::begin() const
}
template
<
int
nBits
>
template
<
unsigned
nBits
>
inline
typename
Foam
::
PackedList
<
nBits
>::
const_iterator
Foam
::
PackedList
<
nBits
>::
cbegin
()
const
{
...
...
@@ -563,7 +563,7 @@ Foam::PackedList<nBits>::cbegin() const
}
template
<
int
nBits
>
template
<
unsigned
nBits
>
inline
typename
Foam
::
PackedList
<
nBits
>::
iterator
Foam
::
PackedList
<
nBits
>::
end
()
{
...
...
@@ -571,7 +571,7 @@ Foam::PackedList<nBits>::end()
}
template
<
int
nBits
>
template
<
unsigned
nBits
>
inline
typename
Foam
::
PackedList
<
nBits
>::
const_iterator
Foam
::
PackedList
<
nBits
>::
end
()
const
{
...
...
@@ -579,7 +579,7 @@ Foam::PackedList<nBits>::end() const
}
template
<
int
nBits
>
template
<
unsigned
nBits
>
inline
typename
Foam
::
PackedList
<
nBits
>::
const_iterator
Foam
::
PackedList
<
nBits
>::
cend
()
const
{
...
...
@@ -589,21 +589,21 @@ Foam::PackedList<nBits>::cend() const
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template
<
int
nBits
>
template
<
unsigned
nBits
>
inline
Foam
::
label
Foam
::
PackedList
<
nBits
>::
size
()
const
{
return
size_
;
}
template
<
int
nBits
>
template
<
unsigned
nBits
>
inline
bool
Foam
::
PackedList
<
nBits
>::
empty
()
const
{
return
!
size_
;
}
template
<
int
nBits
>
template
<
unsigned
nBits
>
inline
void
Foam
::
PackedList
<
nBits
>::
resize
(
const
label
nElem
,
...
...
@@ -674,7 +674,7 @@ inline void Foam::PackedList<nBits>::resize
}
template
<
int
nBits
>
template
<
unsigned
nBits
>
inline
void
Foam
::
PackedList
<
nBits
>::
setSize
(
const
label
newSize
,
...
...
@@ -686,14 +686,14 @@ inline void Foam::PackedList<nBits>::setSize
template
<
int
nBits
>
template
<
unsigned
nBits
>
inline
Foam
::
label
Foam
::
PackedList
<
nBits
>::
capacity
()
const
{
return
packing
()
*
StorageList
::
size
();
}
template
<
int
nBits
>
template
<
unsigned
nBits
>
inline
void
Foam
::
PackedList
<
nBits
>::
setCapacity
(
const
label
nElem
)
{
StorageList
::
setSize
(
packedLength
(
nElem
),
0u
);
...
...
@@ -706,7 +706,7 @@ inline void Foam::PackedList<nBits>::setCapacity(const label nElem)
}
template
<
int
nBits
>
template
<
unsigned
nBits
>
inline
void
Foam
::
PackedList
<
nBits
>::
reserve
(
const
label
nElem
...
...
@@ -722,14 +722,14 @@ inline void Foam::PackedList<nBits>::reserve
}
template
<
int
nBits
>