STRUCT INTERVAL_TREE_SPAN_ITER(9)
π¦ NAME π¦
ok so this is a page from the Kernel API Manual (the <kbd>9</kbd> section, iykyk) and it's all about struct interval_tree_span_iter β literally its whole job is Find used and unused spans. bestie that's it, that's the vibe π
β¨ SYNOPSIS β¨
here's the struct, character for character, no cap:
struct interval_tree_span_iter {
union {
unsigned long start_hole;
unsigned long start_used;
};
union {
unsigned long last_hole;
unsigned long last_used;
};
int is_hole;
};
π Members π
okay let's meet the cast π
{unnamed_union}β anonymous. yes bestie, it has no name, it's mysterious like that πstart_holeβ Start of an interval for a hole whenis_hole == 1start_usedβ Start of a used interval whenis_hole == 0{unnamed_union}β anonymous again. two anonymous unions, they're twins π«Άlast_holeβ Inclusive end of an interval for a hole whenis_hole == 1last_usedβ Inclusive end of a used interval whenis_hole == 0is_holeβ0== used,1== is_hole,-1== done iteration β
tiny note bestie: those last_* fields are inclusive ends, not exclusive. don't come for me, that's just what the page says π
πΈ Description πΈ
okay so picture this: this iterator travels over spans in an interval tree π₯ and here's the plot twist β it does not return nodes. instead it classifies each span as either a hole, where no nodes intersect, or a used, which is fully covered by nodes. it's giving main character energy with a whole identity of its own π
each iteration step toggles between hole and used until the entire range is covered. and the returned spans? they always fully cover the requested range. always. periodt β¨
also the iterator is greedy π β it always returns the largest hole or used possible, consolidating all consecutive nodes. it's not here to be subtle, it wants the biggest span and it gets it π
Use interval_tree_span_iter_done to detect end of iteration. that's your "are we there yet" check, don't skip it π§
π SEE ALSO π
- Kernel file
./include/linux/interval_tree.h
and that's the whole page bestie π β brought to you by ./include/linux, dated October 2026, from the struct inter...ee_span_iter(9) corner of the Kernel API Manual. go forth and iterate, ily ππ¦β¨
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms