Skip to content
GitLab
Menu
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-plus
Commits
ca45cf16
Commit
ca45cf16
authored
Jun 04, 2016
by
Henry Weller
Browse files
DynamicList: minor cleanup
parent
91e84b90
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/OpenFOAM/containers/Lists/DynamicList/DynamicListI.H
View file @
ca45cf16
...
...
@@ -28,11 +28,8 @@ License
template
<
class
T
,
unsigned
SizeInc
,
unsigned
SizeMult
,
unsigned
SizeDiv
>
inline
Foam
::
DynamicList
<
T
,
SizeInc
,
SizeMult
,
SizeDiv
>::
DynamicList
()
:
List
<
T
>
(
0
),
capacity_
(
0
)
{
List
<
T
>::
size
(
0
);
}
{}
template
<
class
T
,
unsigned
SizeInc
,
unsigned
SizeMult
,
unsigned
SizeDiv
>
...
...
@@ -144,28 +141,14 @@ inline void Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::reserve
const
label
nElem
)
{
// Allocate more capacity
?
// Allocate more capacity
if necessary
if
(
nElem
>
capacity_
)
{
// TODO: convince the compiler that division by zero does not occur
// if (SizeInc && (!SizeMult || !SizeDiv))
// {
// // resize with SizeInc as the granularity
// capacity_ = nElem;
// unsigned pad = SizeInc - (capacity_ % SizeInc);
// if (pad != SizeInc)
// {
// capacity_ += pad;
// }
// }
// else
{
capacity_
=
max
(
nElem
,
label
(
SizeInc
+
capacity_
*
SizeMult
/
SizeDiv
)
);
}
capacity_
=
max
(
nElem
,
label
(
SizeInc
+
capacity_
*
SizeMult
/
SizeDiv
)
);
// Adjust allocated size, leave addressed size untouched
label
nextFree
=
List
<
T
>::
size
();
...
...
@@ -181,28 +164,14 @@ inline void Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::setSize
const
label
nElem
)
{
// Allocate more capacity
?
// Allocate more capacity
if necessary
if
(
nElem
>
capacity_
)
{
// TODO: convince the compiler that division by zero does not occur
// if (SizeInc && (!SizeMult || !SizeDiv))
// {
// // resize with SizeInc as the granularity
// capacity_ = nElem;
// unsigned pad = SizeInc - (capacity_ % SizeInc);
// if (pad != SizeInc)
// {
// capacity_ += pad;
// }
// }
// else
{
capacity_
=
max
(
nElem
,
label
(
SizeInc
+
capacity_
*
SizeMult
/
SizeDiv
)
);
}
capacity_
=
max
(
nElem
,
label
(
SizeInc
+
capacity_
*
SizeMult
/
SizeDiv
)
);
List
<
T
>::
setSize
(
capacity_
);
}
...
...
@@ -289,8 +258,9 @@ template<class T, unsigned SizeInc, unsigned SizeMult, unsigned SizeDiv>
inline
void
Foam
::
DynamicList
<
T
,
SizeInc
,
SizeMult
,
SizeDiv
>::
transfer
(
List
<
T
>&
lst
)
{
// Take over storage, clear addressing for lst.
capacity_
=
lst
.
size
();
List
<
T
>::
transfer
(
lst
);
// Take over storage, clear addressing for lst.
List
<
T
>::
transfer
(
lst
);
}
...
...
@@ -304,7 +274,6 @@ Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::transfer
// Take over storage as-is (without shrink), clear addressing for lst.
capacity_
=
lst
.
capacity_
;
lst
.
capacity_
=
0
;
List
<
T
>::
transfer
(
static_cast
<
List
<
T
>&>
(
lst
));
}
...
...
@@ -342,7 +311,7 @@ Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::append
if
(
this
==
&
lst
)
{
FatalErrorInFunction
<<
"
a
ttempted appending to self"
<<
abort
(
FatalError
);
<<
"
A
ttempted appending to self"
<<
abort
(
FatalError
);
}
label
nextFree
=
List
<
T
>::
size
();
...
...
@@ -429,7 +398,7 @@ inline void Foam::DynamicList<T, SizeInc, SizeMult, SizeDiv>::operator=
if
(
this
==
&
lst
)
{
FatalErrorInFunction
<<
"
a
ttempted assignment to self"
<<
abort
(
FatalError
);
<<
"
A
ttempted assignment to self"
<<
abort
(
FatalError
);
}
if
(
capacity_
>=
lst
.
size
())
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment