5 ms·
That is called an index. If you want it to be standalone, you can bundle it with the ArrayList.
by afdbcreid 1mo ago
That is called an index. If you want it to be standalone, you can bundle it with the ArrayList.
- sparkie 1mo agoI think parent was after base+offset+index rather than just base+index. Examples would be eg, `string_view` or `ArraySegment`. They hold some offset relative to a base allocation, and when we index the string_view or ArraySegment we're indexing relative to that offset.
- tialaramex 1mo agoPresumably `string_view` is referring to C++ std::string_view ? It's not holding an "offset", it's a fat pointer, (ptr,len) or possibly (start,end) You're imagining this as (string_ptr,offset,len) but that's 50% bigger for no practical benefit, you cannot unwind a std::string_view to get the string it's a view into, indeed there may never have been such a string.
- pocksuppet 1mo agoThat is called pointer arithmetic on the base
- dminik 1mo agoI wish languages made it easier (or possible) to track index ownership at compile time.
- afdbcreid 1mo agoYou can in Rust! You just bundle it with a lifetime. But... This loses the reason people are using indices to begin with: because the borrow checker cannot track what they do.