Add set/reset/flip functions to change sequences (#27)

* Add set(pos, len) function to change sequences
* Add reset(pos, len) function to clear sequences
* Add flip(pos, len) function to flip sequences
* Add custom range operations
This commit is contained in:
Evgeny Shulgin
2018-10-12 15:07:01 +03:00
committed by James E. King III
parent a0735943f2
commit a449a11a80
4 changed files with 308 additions and 0 deletions

View File

@@ -8,6 +8,7 @@
Copyright (c) 2003-2004, 2008 Gennaro Prota
Copyright (c) 2014 Ahmed Charles
Copyright (c) 2014 Riccardo Marcangelo
Copyright (c) 2018 Evgeny Shulgin
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt or copy at
@@ -197,10 +198,13 @@ public:
dynamic_bitset <a href="#op-sl">operator&lt;&lt;</a>(size_type n) const;
dynamic_bitset <a href="#op-sr">operator&gt;&gt;</a>(size_type n) const;
dynamic_bitset&amp; <a href="#set3">set</a>(size_type n, size_type len, bool val = true);
dynamic_bitset&amp; <a href="#set2">set</a>(size_type n, bool val = true);
dynamic_bitset&amp; <a href="#set1">set</a>();
dynamic_bitset&amp; <a href="#reset3">reset</a>(size_type n, size_type len);
dynamic_bitset&amp; <a href="#reset2">reset</a>(size_type n);
dynamic_bitset&amp; <a href="#reset1">reset</a>();
dynamic_bitset&amp; <a href="#flip3">flip</a>(size_type n, size_type len);
dynamic_bitset&amp; <a href="#flip2">flip</a>(size_type n);
dynamic_bitset&amp; <a href="#flip1">flip</a>();
bool <a href="#test">test</a>(size_type n) const;
@@ -1062,6 +1066,18 @@ dynamic_bitset&amp; <a id="reset1">reset</a>()
<b>Returns:</b> <tt>*this</tt><br />
<b>Throws:</b> nothing.
<hr />
<pre>
dynamic_bitset&amp; <a id=
"set3">set</a>(size_type n, size_type len, bool val = true);
</pre>
<b>Precondition:</b> <tt>n + len &lt; this-&gt;size()</tt>.<br />
<b>Effects:</b> Sets every bit indexed from <tt>n</tt> to
<tt>n + len - 1</tt> inclusively if <tt>val</tt> is <tt>true</tt>, and
clears them if <tt>val</tt> is <tt>false</tt>. <br />
<b>Returns:</b> <tt>*this</tt>
<hr />
<pre>
dynamic_bitset&amp; <a id=
@@ -1074,6 +1090,17 @@ dynamic_bitset&amp; <a id=
<tt>false</tt>. <br />
<b>Returns:</b> <tt>*this</tt>
<hr />
<pre>
dynamic_bitset&amp; <a id=
"reset3">reset</a>(size_type n, size_type len);
</pre>
<b>Precondition:</b> <tt>n + len &lt; this-&gt;size()</tt>.<br />
<b>Effects:</b> Clears every bit indexed from <tt>n</tt> to
<tt>n + len - 1</tt> inclusively.<br />
<b>Returns:</b> <tt>*this</tt>
<hr />
<pre>
dynamic_bitset&amp; <a id="reset2">reset</a>(size_type n)
@@ -1083,6 +1110,16 @@ dynamic_bitset&amp; <a id="reset2">reset</a>(size_type n)
<b>Effects:</b> Clears bit <tt>n</tt>.<br />
<b>Returns:</b> <tt>*this</tt>
<hr />
<pre>
dynamic_bitset&amp; <a id="flip3">flip</a>(size_type n, size_type len)
</pre>
<b>Precondition:</b> <tt>n + len &lt; this-&gt;size()</tt>.<br />
<b>Effects:</b> Flips every bit indexed from <tt>n</tt> to
<tt>n + len - 1</tt> inclusively.<br />
<b>Returns:</b> <tt>*this</tt>
<hr />
<pre>
dynamic_bitset&amp; <a id="flip2">flip</a>(size_type n)