To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.off-topic.geekOpen lugnet.off-topic.geek in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Off-Topic / Geek / 2629
2628  |  2630
Subject: 
Bitstring vector to list conversion in Perl5
Newsgroups: 
lugnet.off-topic.geek
Date: 
Wed, 3 Jan 2001 17:45:17 GMT
Viewed: 
79 times
  
Anyone know of a super-efficient way in Perl5 to convert a sparse bitstring
vector to a list of integer-offset values (just the 1-bits) in Perl5?

That is, if you had some $v that was created like so:

   my $v;
   my @n = (...some sorted sparse list of positive integer values...);
   foreach (@n) { vec($v,$_,1) = 1; }

then what's the fastest way to regenerate @n later given $v ?   Bitstring
vectors can be |'d, &'d, and ^'d super-efficiently in Perl5, but I don't know
the most efficient way to treat them as sparse lists -- i.e., looping over
just the bits that are set and ignoring the bits that aren't set.

--Todd



Message has 1 Reply:
  Re: Bitstring vector to list conversion in Perl5
 
(...) well, I can think of several ways of doing it, but since $v might be millions of bits long, we don't really want to get the full list in memory ever. So I guess the simplest way would be to run through the vector, indexing the 1s: (...) (24 years ago, 3-Jan-01, to lugnet.off-topic.geek)

3 Messages in This Thread:

Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR