mirror of
https://github.com/dlang/phobos.git
synced 2025-04-27 21:51:40 +03:00
Fix Issue 20241 - BitArray.bitsSet ignores length
This commit is contained in:
parent
01fd74a699
commit
289149a2f1
1 changed files with 19 additions and 5 deletions
|
@ -2585,12 +2585,16 @@ public:
|
|||
@property auto bitsSet() const nothrow
|
||||
{
|
||||
import std.algorithm.iteration : filter, map, joiner;
|
||||
import std.range : iota;
|
||||
import std.range : iota, chain;
|
||||
|
||||
return iota(dim).
|
||||
filter!(i => _ptr[i])().
|
||||
map!(i => BitsSet!size_t(_ptr[i], i * bitsPerSizeT))().
|
||||
joiner();
|
||||
return chain(
|
||||
iota(fullWords)
|
||||
.filter!(i => _ptr[i])()
|
||||
.map!(i => BitsSet!size_t(_ptr[i], i * bitsPerSizeT))()
|
||||
.joiner(),
|
||||
iota(fullWords * bitsPerSizeT, _len)
|
||||
.filter!(i => this[i])()
|
||||
);
|
||||
}
|
||||
|
||||
///
|
||||
|
@ -2630,6 +2634,16 @@ public:
|
|||
assert(b.bitsSet.equal(iota(wordBits * 2)));
|
||||
}
|
||||
|
||||
// Issue 20241
|
||||
@system unittest
|
||||
{
|
||||
BitArray ba;
|
||||
ba.length = 2;
|
||||
ba[1] = 1;
|
||||
ba.length = 1;
|
||||
assert(ba.bitsSet.empty);
|
||||
}
|
||||
|
||||
private void formatBitString(Writer)(auto ref Writer sink) const
|
||||
{
|
||||
if (!length)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue