digitalmars.D - Phobos degrades: ndslice vs (BitArray + Bitwise)
- Ilya Yaroshenko (45/45) Dec 07 2016 Phobos is degrades. There is a good example:
- jmh530 (4/5) Dec 07 2016 I think I understand what you mean here, but there's definitely a
- Ilya Yaroshenko (4/10) Dec 07 2016 Yes, my bad. In Russian it has not so big negative shade like in
Phobos is degrades. There is a good example: 1. We have BitArray in std.bitmanip: 2. We are going to add Bitwise, 300+ LOC in std.range https://github.com/dlang/phobos/pull/4927 The code below represents ndslice implementation. The benefits are: 1. It is faster then Bitwise. 2. It has (all) range primitives comparing with BitArray. 3. Its implementation is very simple. 4. multidimensional analog out of the box 5. All ndslice iterators and selectors are available. We are adding new and new API, more and more code and specializations into Phobos. This is bad direction. Small number of basic universal concepts it much more better then soup consisting of "everything you may need". -------------- import core.bitop; import std.experimental.ndslice; struct BitMap { size_t* ptr; bool opIndex(size_t index) const { return bt(ptr, index) != 0; } void opIndexAssign(bool val, size_t index) { if(val) bts(ptr, index); else btr(ptr, index); } } void main() { auto arr = new size_t[3]; auto sl = BitMap(arr.ptr).sliced(size_t.sizeof * 8 * arr.length); sl[4] = true; sl[100] = true; sl.popFrontN(3); // La-la-la assert(sl[1]); assert(sl[97]); }
Dec 07 2016
On Wednesday, 7 December 2016 at 11:39:06 UTC, Ilya Yaroshenko wrote:Phobos is degrades.I think I understand what you mean here, but there's definitely a translation issue.
Dec 07 2016
On Wednesday, 7 December 2016 at 15:11:36 UTC, jmh530 wrote:On Wednesday, 7 December 2016 at 11:39:06 UTC, Ilya Yaroshenko wrote:Yes, my bad. In Russian it has not so big negative shade like in English. Andrei proposed a good solution for the Bitwise problem. --IlyaPhobos is degrades.I think I understand what you mean here, but there's definitely a translation issue.
Dec 07 2016