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
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
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
Core Modules
dune-common
Commits
2de2a21f
Commit
2de2a21f
authored
20 years ago
by
Oliver Sander
Browse files
Options
Downloads
Patches
Plain Diff
An array of booleans. Inherits from std::vector<bool>
[[Imported from SVN: r1132]]
parent
8606759c
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
common/bitfield.hh
+55
-0
55 additions, 0 deletions
common/bitfield.hh
with
55 additions
and
0 deletions
common/bitfield.hh
0 → 100644
+
55
−
0
View file @
2de2a21f
// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
// vi: set et ts=4 sw=2 sts=2:
#ifndef DUNE_BITFIELD_HH
#define DUNE_BITFIELD_HH
#include
<vector>
namespace
Dune
{
/** \brief A dynamic array of booleans
* \ingroup Common
*
* This class is basically std::vector<bool>, but with a few added
* methods.
*/
class
BitField
:
public
std
::
vector
<
bool
>
{
public:
//! Sets all entries to <tt> true </tt>
void
setAll
()
{
for
(
int
i
=
0
;
i
<
size
();
i
++
)
(
*
this
)[
i
]
=
true
;
}
//! Sets all entries to <tt> false </tt>
void
unsetAll
()
{
for
(
int
i
=
0
;
i
<
size
();
i
++
)
(
*
this
)[
i
]
=
false
;
}
//! Returns the number of set bits
int
nSetBits
()
const
{
int
n
=
0
;
for
(
int
i
=
0
;
i
<
size
();
i
++
)
n
+=
((
*
this
)[
i
])
?
1
:
0
;
return
n
;
}
//! Send bitfield to an output stream
friend
std
::
ostream
&
operator
<<
(
std
::
ostream
&
s
,
const
BitField
&
v
)
{
for
(
int
i
=
0
;
i
<
v
.
size
();
i
++
)
s
<<
v
[
i
]
<<
" "
;
s
<<
std
::
endl
;
return
s
;
}
};
}
#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