Perl: the Markov chain saw PerlMonks

### Re^2: Serializing a large object

by daverave (Scribe)
 on Sep 25, 2010 at 19:11 UTC ( #861990=note: print w/replies, xml ) Need Help??

in reply to Re: Serializing a large object
in thread Serializing a large object

The ranges are given in biological coordinates, meaning the first coordinate is 1 (0 is illegal) and max_length is a legal coordinate. So, if max_length=10 then our coordinates are in 1..10 (both inclusive). Also note that a range like [2,4] expands to2,3,4 since both start and end are inclusive.

This convention always causes some trouble, and most of the time I use to convert the coordinates at the beginning and at the end so I can work with 0-based coordinates. In this case I didn't since it's quite simple, so I'm working with biological coordinates.

Anyway, if we now take your example and arbitrarily replace all 0's with 1's we get:

```my @ranges = ([ 1, 5 ], [ 1, 6 ], [ 2, 7 ], [ 3, 8 ], [ 4, 9 ], [ 5,
+10 ],[ 5, 1 ], [ 6, 1 ], [ 7, 2 ], [ 8, 3 ], [ 9, 4 ], [ 10, 5 ],);
my \$rm = RangeMap->new( 10, \@ranges );

Now, [1,3] returns 5; since only the first two and last three ranges contain it.

[1,4] returns 4; since only the first two and last two ranges contain it.

I hope it makes sense now

Replies are listed 'Best First'.
Re^3: Serializing a large object
by BrowserUk (Pope) on Sep 25, 2010 at 19:43 UTC

So, an inverted range like [9, 4] includes: 1,2,3,4 & 9,10?

Exactly.

Then I still don't understand the returns from num_ranges_containing().

Given the input you describe, [7,10] matches [5,10], [5,1], [6,1], & [7,2], but it returns 1 (not 4)?

```c:\test>861961
12345                1.. 5
123456               1.. 6
234567              2.. 7
345678             3.. 8
456789            4.. 9
567890           5..10
1   567890           5.. 1
1    67890           6.. 1
12    7890           7.. 2
123    890           8.. 3
1234    90           9.. 4
12345    0          10.. 5

1234                 1.. 4     RM1: range:  1 ..  4 is contained by 4
+ ranges
2345                2.. 5     RM1: range:  2 ..  5 is contained by 4
+ ranges
3456               3.. 6     RM1: range:  3 ..  6 is contained by 3
+ ranges
4567              4.. 7     RM1: range:  4 ..  7 is contained by 3
+ ranges
5678             5.. 8     RM1: range:  5 ..  8 is contained by 3
+ ranges
6789            6.. 9     RM1: range:  6 ..  9 is contained by 2
+ ranges
7890           7..10     RM1: range:  7 .. 10 is contained by 1
+ ranges

Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

Create A New User
Node Status?
node history
Node Type: note [id://861990]
help
Chatterbox?
 [marto]: Corion, I think in the past this was a big problem for them. GPU driver wise the improve all the time. I use the open source drivers on my machine (old R9 270, 2GB) and had no problems [Discipulus]: is not the problem with new hardware? [marto]: notepad++ ticks all the boxes for me, it's a fine line between just enough, and bloat, in editors for me :P [marto]: Discipulus]: less so than the modern intel CPUs [marto]: also, AMD are faster at fixing the CPU microcode it would seem

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (8)
As of 2017-07-27 08:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
Voting Booth?
I came, I saw, I ...

Results (407 votes). Check out past polls.