in reply to Re: Re: evolving an OO solution for a bitstream
in thread evolving an OO solution for a bitstream
# This way of dealing with meg and gig is a poor way, used only for de +monstration. # Supersearch for a better way. my $KB = 1024; my $MB = 1024 * $KB; my $GB = 1024 * $MB; my %Classes = ( $MB => 'BitStream::Vec', $GB => 'BitStream::Buffered', ); my $filesize = -s $filename; my $classname = 'BitStream::InMemory'; foreach my $min_size (sort { $a <=> $b } keys %Classes) { last unless $filesize >= $min_size; $classname = $classes{$min_size}; } my $stream = $classname->new($filename);
That way, you can choose your BitStream::* class based on the size of your file. If it's under a meg, use the instream. Between a meg and a gig, use the hybrid vec option. Over a gig, you need to use the slow buffered method.
------
We are the carpenters and bricklayers of the Information Age.
The idea is a little like C++ templates, except not quite so brain-meltingly complicated. -- TheDamian, Exegesis 6
... strings and arrays will suffice. As they are easily available as native data types in any sane language, ... - blokhead, speaking on evolutionary algorithms
Please remember that I'm crufty and crochety. All opinions are purely mine and all code is untested, unless otherwise specified.
|
|---|