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
b46dbeac
Commit
b46dbeac
authored
20 years ago
by
Markus Blatt
Browse files
Options
Downloads
Patches
Plain Diff
Modified documentation.
[[Imported from SVN: r1003]]
parent
db69bcf7
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
common/arraylist.hh
+57
-22
57 additions, 22 deletions
common/arraylist.hh
with
57 additions
and
22 deletions
common/arraylist.hh
+
57
−
22
View file @
b46dbeac
...
...
@@ -5,7 +5,12 @@
#include
<vector>
#include
<dune/common/fixedarray.hh>
/**
* @file This file implements the class ArrayList which behaves like
* dynamically growing array together with
* the class ArrayListIterator which is random access iterator as needed
* by the stl for sorting and other algorithms.
*/
namespace
Dune
{
// forward declaration
template
<
class
T
,
int
N
>
...
...
@@ -29,31 +34,42 @@ namespace std {
namespace
Dune
{
/** @addtogroup Common
*
* @{
*/
/**
* @brief A random access data structure.
* @brief A dynamically growing random access list.
*
* Internally the data is organized in a list of arrays of fixed size. Whenever the capacity
* of the array list is not sufficient a new Array is allocated. In contrast to
* of the array list is not sufficient a new
Dune::Fixed
Array is allocated. In contrast to
* std::vector this approach prevents data copying. On the outside
* we provide the same interface as the stl random access containers.
*/
template
<
class
T
,
int
N
=
100
>
class
ArrayList
{
public:
/**
* @brief The member type.
*/
typedef
T
memberType
;
/**
* @brief The number of elements in one chunk of the list.
* This has to be at least one. The default is 100.
* @brief The iterator needs access to the private variables.
*/
enum
{
chunkSize_
=
(
N
>
0
)
?
N
:
1
}
;
friend
class
ArrayListIterator
<
T
,
N
>
;
public:
/**
* @brief The iterator needs access to the private variables.
* @brief The member type that is stored.
*
* Has to be assignable and has to have an empty constructor.
*/
friend
class
ArrayListIterator
<
memberType
,
N
>
;
typedef
T
memberType
;
enum
{
/**
* @brief The number of elements in one chunk of the list.
* This has to be at least one. The default is 100.
*/
chunkSize_
=
(
N
>
0
)
?
N
:
1
};
/**
* @brief A random access iterator.
...
...
@@ -97,8 +113,7 @@ namespace Dune {
*/
void
push_back
(
const
T
&
entry
);
/**
* @brief Constructor.
* Constructs an Array list with one chunk.
* @brief Constructs an Array list with one chunk.
*/
ArrayList
();
...
...
@@ -146,6 +161,9 @@ namespace Dune {
template
<
class
T
,
int
N
>
bool
operator
>=
(
const
ArrayListIterator
<
T
,
N
>&
a
,
const
ArrayListIterator
<
T
,
N
>&
b
);
/**
* @brief A random access iterator for the Dune::ArrayList class.
*/
template
<
class
T
,
int
N
>
class
ArrayListIterator
{
...
...
@@ -166,11 +184,15 @@ namespace Dune {
*/
typedef
T
memberType
;
/**
* @brief The number of elements in one chunk of the list.
* This has to be at least one. The default is 100.
*/
enum
{
chunkSize_
=
(
N
>
0
)
?
N
:
1
};
enum
{
/**
* @brief The number of elements in one chunk of the list.
*
* This has to be at least one. The default is 100.
*/
chunkSize_
=
(
N
>
0
)
?
N
:
1
};
/**
* @brief Comares to iterators.
...
...
@@ -214,8 +236,8 @@ namespace Dune {
const
ArrayListIterator
<
memberType
,
N
>&
operator
+=
(
int
count
);
/**
* @brief Decrem
n
ets the iterator by an arbitrary value of positions.
* @param count The number of positions to
advance
.
* @brief Decreme
n
ts the iterator by an arbitrary value of positions.
* @param count The number of positions to
decrement
.
* @return The iterator at that position.
*/
const
ArrayListIterator
<
memberType
,
N
>&
operator
-=
(
int
count
);
...
...
@@ -232,6 +254,12 @@ namespace Dune {
*/
memberType
&
operator
*
()
const
;
/**
* @brief Returns a pointer to the current entry.
* @return A pointer to the current entry.
*/
memberType
*
operator
->
()
const
;
const
ArrayListIterator
<
memberType
,
N
>&
operator
=
(
const
ArrayListIterator
<
memberType
,
N
>&
other
);
ArrayListIterator
(
const
ArrayListIterator
<
memberType
,
N
>&
other
);
...
...
@@ -414,6 +442,11 @@ namespace Dune {
return
list_
.
chunks_
[
position_
/
chunkSize_
]
->
operator
[](
position_
%
chunkSize_
);
}
template
<
class
T
,
int
N
>
T
*
ArrayListIterator
<
T
,
N
>::
operator
->
()
const
{
return
&
(
list_
.
chunks_
[
position_
/
chunkSize_
]
->
operator
[](
position_
%
chunkSize_
));
}
template
<
class
T
,
int
N
>
const
ArrayListIterator
<
T
,
N
>&
ArrayListIterator
<
T
,
N
>::
operator
=
(
const
ArrayListIterator
<
T
,
N
>&
other
){
position_
=
other
.
position_
;
...
...
@@ -428,5 +461,7 @@ namespace Dune {
template
<
class
T
,
int
N
>
ArrayListIterator
<
T
,
N
>::
ArrayListIterator
(
const
ArrayListIterator
<
T
,
N
>&
other
)
:
position_
(
other
.
position_
),
list_
(
other
.
list_
){}
/** @} */
}
#endif
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