Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Slice Intersection in D

Have anybody implemented intersections for array slices that overlap in memory? Algorithm returns [] upon no overlap.

I want this when pretty-printing (using overlap indentation) arrays slices that overlap in memory.

like image 334
Nordlöw Avatar asked May 29 '26 16:05

Nordlöw


1 Answers

if you are sure they are arrays then just take the difference of the ptr fields:

size_t startoffset = b.ptr-a.ptr
like image 198
ratchet freak Avatar answered Jun 01 '26 22:06

ratchet freak



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!