Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Development
openfoam
Commits
d2d39c32
Commit
d2d39c32
authored
Dec 08, 2009
by
Mark Olesen
Browse files
HashSet and PackedList get an unset() method
- provides a convenient (and lazy) means of removing entries
parent
16c715ce
Changes
4
Hide whitespace changes
Inline
Side-by-side
applications/test/PackedList1/PackedListTest1.C
View file @
d2d39c32
...
...
@@ -58,9 +58,15 @@ int main(int argc, char *argv[])
list1
.
print
(
Info
);
Info
<<
"
\n
test set() with default argument (max_value)
\n
"
;
list1
.
set
(
1
);
list1
.
set
(
3
);
list1
.
print
(
Info
);
Info
<<
"
\n
test unset() with in-range and out-of-range
\n
"
;
list1
.
unset
(
3
);
list1
.
unset
(
100000
);
list1
.
print
(
Info
);
Info
<<
"
\n
test assign between references
\n
"
;
list1
[
2
]
=
3
;
list1
[
4
]
=
list1
[
2
];
...
...
src/OpenFOAM/containers/HashTables/HashSet/HashSet.H
View file @
d2d39c32
...
...
@@ -136,6 +136,12 @@ public:
return
insert
(
lst
);
}
//- Unset the specified key - same as erase
bool
unset
(
const
Key
&
key
)
{
return
HashTable
<
nil
,
Key
,
Hash
>::
erase
(
key
);
}
// Member Operators
...
...
src/OpenFOAM/containers/Lists/PackedList/PackedList.H
View file @
d2d39c32
...
...
@@ -201,6 +201,10 @@ public:
// Default value set is the max_value.
inline
bool
set
(
const
label
,
const
unsigned
int
val
=
~
0u
);
//- Unset the entry at index I. Return true if value changed.
// Never auto-vivify entries.
inline
bool
unset
(
const
label
);
//- Return the underlying packed storage
inline
List
<
unsigned
int
>&
storage
();
...
...
@@ -240,6 +244,8 @@ public:
//- Reserve allocation space for at least this size.
// Never shrinks the allocated size.
// The list size is adjusted as per DynamicList with
// SizeInc=0, SizeMult=2, SizeDiv=1
inline
void
reserve
(
const
label
);
//- Clear the list, i.e. set addressable size to zero.
...
...
@@ -249,7 +255,7 @@ public:
//- Clear the list and delete storage.
inline
void
clearStorage
();
//- Shrink the allocated space to what is used.
//- Shrink the allocated space to what is
actually
used.
inline
void
shrink
();
//- Transfer the contents of the argument list into this list
...
...
src/OpenFOAM/containers/Lists/PackedList/PackedListI.H
View file @
d2d39c32
...
...
@@ -810,6 +810,19 @@ inline bool Foam::PackedList<nBits>::set
}
template
<
unsigned
nBits
>
inline
bool
Foam
::
PackedList
<
nBits
>::
unset
(
const
label
i
)
{
// lazy - ignore out-of-bounds
if
(
i
<
0
||
i
>=
size_
)
{
return
false
;
}
return
iteratorBase
(
this
,
i
).
set
(
0u
);
}
template
<
unsigned
nBits
>
inline
void
Foam
::
PackedList
<
nBits
>::
append
(
const
unsigned
int
val
)
{
...
...
Write
Preview
Markdown
is supported
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