Steve, thank you once again. Now it compiles & runs!
I now create my tree like this:
auto debs = new RedBlackTree!(Deb, (a, b) => a.name < b.name);
(I feel that the rbtree docs are inadequate regarding creating
new empty trees, so have submitted a bug report:
On 3/7/20 8:22 AM, mark wrote:
0x55701ef0 in
_D3std9container6rbtree__T12RedBlackTreeTAyaVQea5_61203c2062Vbi0ZQBn5emptyMFNaNbNdNiNfZb
(this=0x0)
at
/home/mark/opt/ldc2-1.20.0-linux-x86_64/bin/../import/std/container/rbtree.d:967
967 return _end.left is null;
(gdb) bt
07.03.2020 15:58, Steven Schveighoffer пишет:
Hm... I'd say:
1. Don't use a pointer for the element. Just use the struct directly.
Using a pointer is bad because it's now going to compare pointers, and
not the element data. Not only that, but RBNodes are stored as
heap-allocated structs, so
I've now gone back to using structs direct without pointers but
I'm still doing something wrong.
struct Deb {
string name;
...
RedBlackTree!string tags;
bool valid() { return !(name.empty || description.empty); }
void clear() { name = ""; ...; tags.clear; }
}
On 3/7/20 5:58 AM, mark wrote:
change #1:
if (line.empty) {
if (deb != null && deb.valid)
debs.insert(deb);
else // report incomplete
deb = null;
continue;
07.03.2020 13:58, mark пишет:
change #1:
if (line.empty) {
if (deb != null && deb.valid)
debs.insert(deb);
else // report incomplete
deb = null;
continue;
change #1:
if (line.empty) {
if (deb != null && deb.valid)
debs.insert(deb);
else // report incomplete
deb = null;
continue;
}
if (deb == null)
Instead of deb.clear I'm now doing deb = null;
On Saturday, 7 March 2020 at 10:30:06 UTC, drug wrote:
07.03.2020 13:20, mark пишет:
I have this struct (with details omitted
[ snip ]
Should Deb be a class rather than a struct?
Do you consider using pointers in AA:
```
Deb*[string] debForName;
```
I've done some changes including using
07.03.2020 13:20, mark пишет:
I have this struct (with details omitted
[ snip ]
Should Deb be a class rather than a struct?
Do you consider using pointers in AA:
```
Deb*[string] debForName;
```
I have this struct (with details omitted ... for brevity):
struct Deb {
string name;
...
RedBlackTree!string tags;
void clear() { name = ""; ...; tags.clear; }
bool valid() { return !(name.empty || description.empty); }
}
I plan to store >65K of these (with potential for
11 matches
Mail list logo