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
c540a8e6
Commit
c540a8e6
authored
20 years ago
by
Markus Blatt
Browse files
Options
Downloads
Patches
Plain Diff
Some additional functions and tests.
Removed compiler warning. [[Imported from SVN: r1118]]
parent
7d22ec87
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
common/sllist.hh
+14
-4
14 additions, 4 deletions
common/sllist.hh
common/test/sllisttest.cc
+26
-6
26 additions, 6 deletions
common/test/sllisttest.cc
with
40 additions
and
10 deletions
common/sllist.hh
+
14
−
4
View file @
c540a8e6
...
...
@@ -79,10 +79,7 @@ namespace Dune
*/
inline
void
pop_front
();
/**
* @brief Remove the first item in the list.
* @return The last item in the list or 0 if the list is empty.
/** @brief Remove all elements from the list. */
/** @brief Remove all elements from the list. */
inline
void
clear
();
/**
...
...
@@ -118,6 +115,13 @@ namespace Dune
*/
inline
const_iterator
end
()
const
;
/**
* @brief Check whether the list is empty.
*
* @return True if the list is empty;
*/
inline
bool
empty
()
const
;
private:
struct
Element
{
...
...
@@ -326,6 +330,12 @@ namespace Dune
tail_
=
head_
;
}
template
<
typename
T
,
class
A
>
inline
bool
SLList
<
T
,
A
>::
empty
()
const
{
return
head_
==
0
;
}
template
<
typename
T
,
class
A
>
inline
SLListIterator
<
T
,
A
>
SLList
<
T
,
A
>::
begin
()
{
...
...
This diff is collapsed.
Click to expand it.
common/test/sllisttest.cc
+
26
−
6
View file @
c540a8e6
...
...
@@ -5,8 +5,25 @@
#include
<dune/common/poolallocator.hh>
#include
<iostream>
template
<
class
A
>
void
randomizeListBack
(
Dune
::
SLList
<
double
,
A
>&
alist
){
class
DoubleWrapper
{
public:
DoubleWrapper
(
double
b
)
:
d
(
b
)
{}
operator
double
()
{
return
d
;
}
private
:
double
d
;
};
template
<
typename
T
,
class
A
>
void
randomizeListBack
(
Dune
::
SLList
<
T
,
A
>&
alist
){
using
namespace
Dune
;
srand
((
unsigned
)
time
(
0
));
...
...
@@ -14,11 +31,11 @@ void randomizeListBack(Dune::SLList<double,A>& alist){
int
lowest
=
0
,
highest
=
1000
,
range
=
(
highest
-
lowest
)
+
1
;
for
(
int
i
=
0
;
i
<
10
;
i
++
)
alist
.
push_back
((
range
*
(
rand
()
/
(
RAND_MAX
+
1.0
))));
alist
.
push_back
(
T
(
range
*
(
rand
()
/
(
RAND_MAX
+
1.0
))));
}
template
<
class
A
>
void
randomizeListFront
(
Dune
::
SLList
<
double
,
A
>&
alist
){
template
<
typename
T
,
class
A
>
void
randomizeListFront
(
Dune
::
SLList
<
T
,
A
>&
alist
){
using
namespace
Dune
;
srand
((
unsigned
)
time
(
0
));
...
...
@@ -73,9 +90,11 @@ int main()
Dune
::
SLList
<
double
>
list
;
Dune
::
SLList
<
double
,
Dune
::
PoolAllocator
<
double
,
8
*
1024
-
20
>
>
list1
;
Dune
::
SLList
<
DoubleWrapper
,
Dune
::
PoolAllocator
<
DoubleWrapper
,
8
*
1024
-
20
>
>
list2
;
randomizeListBack
(
list1
);
randomizeListFront
(
list
);
randomizeListFront
(
list2
);
ret
+=
testIterator
(
list
);
ret
+=
testIterator
(
list1
);
...
...
@@ -83,6 +102,7 @@ int main()
list
.
clear
();
list1
.
clear
();
list2
.
clear
();
randomizeListBack
(
list
);
randomizeListFront
(
list1
);
exit
(
ret
);
...
...
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