mirror of
https://github.com/boostorg/dynamic_bitset.git
synced 2026-01-19 04:12:09 +00:00
Add capacity(), reserve(), and shrink_to_fit().
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
Copyright (c) 2001 Jeremy Siek
|
||||
Copyright (c) 2003-2004, 2008 Gennaro Prota
|
||||
Copyright (c) 2014 Ahmed Charles
|
||||
Copyright (c) 2014 Riccardo Marcangelo
|
||||
|
||||
Distributed under the Boost Software License, Version 1.0.
|
||||
(See accompanying file LICENSE_1_0.txt or copy at
|
||||
@@ -219,6 +220,9 @@ public:
|
||||
size_type <a href="#num_blocks">num_blocks</a>() const noexcept;
|
||||
size_type <a href="#max_size">max_size</a>() const noexcept;
|
||||
bool <a href="#empty">empty</a>() const noexcept;
|
||||
size_type <a href="#capacity">capacity</a>() const noexcept;
|
||||
void <a href="#reserve">reserve</a>(size_type num_bits);
|
||||
void <a href="#shrink_to_fit">shrink_to_fit</a>();
|
||||
|
||||
bool <a href="#is_subset_of">is_subset_of</a>(const dynamic_bitset& a) const;
|
||||
bool <a href="#is_proper_subset_of">is_proper_subset_of</a>(const dynamic_bitset& a) const;
|
||||
@@ -843,7 +847,7 @@ void <a id="pop_back">pop_back</a>();
|
||||
<b>Precondition:</b> <tt>!this->empty()</tt>.<br />
|
||||
<b>Effects:</b> Decreases the size of the bitset by one.<br />
|
||||
<b>Throws:</b> nothing.
|
||||
|
||||
|
||||
<hr />
|
||||
<pre>
|
||||
void <a id="push_back">push_back</a>(bool value);
|
||||
@@ -1125,6 +1129,40 @@ bool <a id="empty">empty</a>() const;
|
||||
otherwise. <i>Note</i>: not to be confused with <tt>none()</tt>, that has
|
||||
different semantics.
|
||||
|
||||
<hr />
|
||||
<pre>
|
||||
size_type <a id="capacity">capacity</a>() const;
|
||||
</pre>
|
||||
|
||||
<b>Returns:</b> The total number of elements that <tt>*this</tt> can hold without requiring
|
||||
reallocation.<br />
|
||||
<b>Throws:</b> nothing.
|
||||
|
||||
<hr />
|
||||
<pre>
|
||||
void <a id="reserve">reserve</a>(size_type num_bits);
|
||||
</pre>
|
||||
|
||||
<b>Effects:</b> A directive that informs the bitset of a planned change in size, so that it can
|
||||
manage the storage allocation accordingly. After reserve(), capacity() is greater or equal to the
|
||||
argument of reserve() if reallocation happens; and equal to the previous value of capacity() otherwise.
|
||||
Reallocation happens at this point if and only if the current capacity is less than the argument of
|
||||
reserve(). <br />
|
||||
<i>Note:</i> It does not change the size() of the bitset.<br />
|
||||
<b>Postcondtitions:</b> <tt>this->capacity() >= num_bits</tt>.<br />
|
||||
<b>Throws:</b> An allocation error if memory is exhausted
|
||||
(<tt>std::bad_alloc</tt> if <tt>Allocator=std::allocator</tt>).
|
||||
|
||||
<hr />
|
||||
<pre>
|
||||
void <a id="shrink_to_fit">shrink_to_fit</a>();
|
||||
</pre>
|
||||
|
||||
<b>Effects:</b> shrink_to_fit() is a request to reduce memory use by removing unused capacity.<br />
|
||||
<i>Note:</i> It does not change the size() of the bitset.<br />
|
||||
<b>Throws:</b> An allocation error if memory is exhausted
|
||||
(<tt>std::bad_alloc</tt> if <tt>Allocator=std::allocator</tt>).
|
||||
|
||||
<hr />
|
||||
<pre>
|
||||
size_type <a id="count">count</a>() const
|
||||
@@ -1682,6 +1720,10 @@ href="mailto:cda@freshsources.com">cda@freshsources.com</a>)<br
|
||||
<td>Copyright © 2014</td>
|
||||
<td>Glen Fernandes (<a href="mailto:glenfe@live.com">glenfe@live.com</a>)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Copyright © 2014</td>
|
||||
<td>Riccardo Marcangelo (<a href="mailto:ricky.65@outlook.com">ricky.65@outlook.com</a>)</td>
|
||||
</tr>
|
||||
</table>
|
||||
<br />
|
||||
<div class="legalnotice">
|
||||
|
||||
Reference in New Issue
Block a user