1 #include <ozulis/core/assert.hh>
11 : Singleton
<IdBase
<H
> > (),
22 return IdBase
<H
>::instance().nextId_
++;
27 IdBase
<H
>::setParent(id_t parent
, id_t child
)
31 assert(parent
< child
);
33 IdBase
<H
> & thiz
= IdBase
<H
>::instance();
34 if (thiz
.parents_
.capacity() < child
)
35 thiz
.parents_
.resize((child
+ 128) & 0x7f);
37 thiz
.parents_
[child
] = parent
;
38 thiz
.childs_
[parent
].insert(child
);
43 IdBase
<H
>::parent(id_t child
)
45 IdBase
<H
> & thiz
= IdBase
<H
>::instance();
47 return thiz
.parents_
[child
];
52 IdBase
<H
>::check(id_t parent
, id_t child
)
54 IdBase
<H
> & thiz
= IdBase
<H
>::instance();
56 assert(parent
< child
);
57 id_t currentParent
= thiz
.parents_
[child
];
58 while (currentParent
> parent
)
60 child
= currentParent
;
61 currentParent
= thiz
.parents_
[child
];
63 return currentParent
== parent
;
66 template <typename H
, typename T
>
70 static id_t id_
= IdBase
<H
>::nextId();
74 template <typename H
, typename P
, typename T
>
83 id_t parent
= Id
<H
, P
>::id();
86 IdBase
<H
>::setParent(parent
, id_
);