Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dune-common
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Timo Koch
dune-common
Commits
309f52eb
Commit
309f52eb
authored
19 years ago
by
Markus Blatt
Browse files
Options
Downloads
Patches
Plain Diff
removed seqfault
[[Imported from SVN: r3053]]
parent
d7d81ab1
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
istl/bvector.hh
+20
-44
20 additions, 44 deletions
istl/bvector.hh
with
20 additions
and
44 deletions
istl/bvector.hh
+
20
−
44
View file @
309f52eb
...
...
@@ -301,23 +301,9 @@ namespace Dune {
}
}
/**
* @brief Reserve space. Values will be copied if data is reallocated.
*
* After calling this method the vector can hold up to
* capacity values. If the specified capacity is smaller
* than the current capacity and bigger than the current size
* space will be freed.
* @param capacity The maximum number of elements the vector
* needs to hold.
*/
void
reserve
(
size_type
capacity
)
{
this
->
template
reserve
<
true
>(
capacity
);
}
/**
* @brief Reserve space
without copying if template parameter is false
.
* @brief Reserve space.
*
* After calling this method the vector can hold up to
* capacity values. If the specified capacity is smaller
...
...
@@ -329,9 +315,10 @@ namespace Dune {
*
* @param capacity The maximum number of elements the vector
* needs to hold.
* @param copyOldValues If false no object will be copied and the data might be
* lost.
*/
template
<
bool
copyOldValues
>
void
reserve
(
size_type
capacity
)
void
reserve
(
size_type
capacity
,
bool
copyOldValues
=
true
)
{
if
(
capacity
>=
block_vector_unmanaged
<
B
,
A
>::
N
()
&&
capacity
!=
capacity_
)
{
// save the old data
...
...
@@ -339,7 +326,7 @@ namespace Dune {
if
(
capacity
>
0
)
{
// create new array with capacity
this
->
p
=
A
::
template
malloc
<
B
>(
this
->
n
);
this
->
p
=
A
::
template
malloc
<
B
>(
capacity
);
if
(
copyOldValues
)
{
// copy the old values
...
...
@@ -348,16 +335,18 @@ namespace Dune {
for
(
size_type
i
=
0
;
i
<
block_vector_unmanaged
<
B
,
A
>::
N
();
++
i
,
++
from
,
++
to
)
*
to
=
*
from
;
if
(
capacity_
>
0
)
// free old data
A
::
template
free
<
B
>(
pold
);
}
}
else
{
this
->
p
=
0
;
if
(
capacity_
>
0
)
// free old data
this
->
p
=
0
;
capacity_
=
0
;
}
if
(
capacity_
>
0
)
// free old data
A
::
template
free
<
B
>(
pold
);
capacity_
=
capacity
;
}
}
...
...
@@ -374,22 +363,7 @@ namespace Dune {
}
/**
* @brief Resize the vector. Values will be copied if data is reallocated.
*
* After calling this method ::N() will return size
* If the capacity of the vector is smaller than the specified
* size then reserve(size) will be called.
* The values will be copied if the capacity changes.
* @param size The new size of the vector
*/
void
resize
(
size_type
size
)
{
this
->
template
resize
<
true
>(
size
);
}
/**
* @brief Resize the vector without copying if template parameter is false.
* @brief Resize the vector.
*
* After calling this method ::N() will return size
* If the capacity of the vector is smaller than the specified
...
...
@@ -398,14 +372,15 @@ namespace Dune {
* If the template parameter copyOldValues is true the values
* will be copied if the capacity changes. If it is false
* the old values are lost.
* @param size The new size of the vector
* @param size The new size of the vector.
* @param copyOldValues If false no object will be copied and the data might be
* lost.
*/
template
<
bool
copyOldValues
>
void
resize
(
size_type
size
)
void
resize
(
size_type
size
,
bool
copyOldValues
=
true
)
{
if
(
size
>
block_vector_unmanaged
<
B
,
A
>::
N
())
if
(
capacity_
<
size
)
this
->
template
reserve
<
copyOldValues
>(
size
);
this
->
reserve
(
size
,
copyOldValues
);
if
(
size
>=
0
)
this
->
n
=
size
;
...
...
@@ -534,7 +509,8 @@ namespace Dune {
}
this
->
n
=
a
.
n
;
// copy data
for
(
size_type
i
=
0
;
i
<
this
->
n
;
i
++
)
this
->
p
[
i
]
=
a
.
p
[
i
];
for
(
size_type
i
=
0
;
i
<
this
->
n
;
i
++
)
this
->
p
[
i
]
=
a
.
p
[
i
];
}
return
*
this
;
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment