« first day (4994 days earlier)      last day (170 days later) » 

08:56
Here after I don't know how many years
About 3 years I suppose, how's everyone?
 
6 hours later…
15:13
@twodee \o
@Tiffany o/
 
1 hour later…
16:39
I am getting a bad result on PHP 8.2 on heap.space. @Ekin, is this something you can help with?
^ This does not exist on the PHP-8.2 branch.
17:09
hello
17:35
What's the most efficient data structure for associating a value to range and then retrieving that value by matching a key in that range?

E.g. [ [0..2] => 'a', [4..6] => 'b' ]

in which case, a search key of 1 returns 'a', 3 returns null and 4 returns 'b'.

In my case, it will be typical to have only a few values ('a', 'b' etc) but rather large ranges (0 => 300).

I'm wondering if looping over a list of items (['start'=>0,'end'=>2,'data'=>'a']) would be more efficient than a large indexed array with many entries pointing to the same value ([0=>&objectA, 1=>&objectA, 2=>&objectA, 4=>&objec
17:52
@Christian A tree would be the best data structure for fast lookups. If you only anticipate having a few ranges though, a loop over the list of ranges is probably fine.
To tell the whole story, I'm parsing PHP files into entries of {start-line:int, end-line:int, namespace:string, imports:array} and later on I want to find the namespace and imports at a specific line.
I'm assuming that it is extremely unlikely to have a lot of such items - in most cases it will be one item
so probably it wouldn't make sense to have an array with 400 keys (=400 lines) pointing to the same value (=one namespace).
@Trowski But, for fun's sake, if I did want to use a tree structure, is there something built-in - maybe in spl? It seems to be mentioned for SplHeap.
18:16
In that case, definitely a list. Nothing built in, a heap is not the type of tree you want.
 
2 hours later…
19:47
@Trowski Thanks for the info!

« first day (4994 days earlier)      last day (170 days later) »