I am writing a UI that needs to display a chat log, similar to Slack and Discord. In addition to being able to scroll and lazy-fetch additional pages in either direction, I need to be able to jump to a specific point in time and fetch the message records "around" it (a backend API problem, of course).
I need a "lazy range" data structure that can store "intervals" (each with bounds and an ordered list of items), respond to queries for "more before" or "more after" including items and some kind of indication of gaps, and insert new intervals (pages fetched from the backend), merging existing intervals when overlaps are detected and eliminating the gap indicator.
I have not been able to find an existing named data structure that handles this kind of access pattern. It seems similar to a range tree but has only a single level of interval nodes, and it is similar to an interval tree in that we want to detect bound overlaps/gaps, but then we want to merge overlaps. Does such a data structure already exist?