Boost logo

Boost :

From: Gary Powell (Gary.Powell_at_[hidden])
Date: 2000-10-20 16:24:17


So were you thinking of something like this:

class runlength_encode {
runlengthdata;
public
   runlength_encode (escape = 0);
};

class runlength_decode {
runlengthdata;
public
   runlength_decode (escape = 0);
};

int boost::encode(runlength_encode, inputIterator first, inputIterator last,
outputIterator result);

int boost:decode(runlength_decode, inputIterator first, inputIterator last,
outputIterator result);

Where the special information needed by the encoder and the decoder is built
into the runlength_encode and runlength_decode classes?
Then the encode and decode fns are just specializations?

Alternatively you could create a "compression" view and use std::copy.

vector<int> v;
runlength_compression rlc(0);

filter_view<
        vector<int>,
        runlength_compression,
        const_tag,
        forward_iterator_rag >
 cp(v,runlength_compression(escapeValue) );

copy(cp.begin(), cp.end(), back_inserter(X) );
cout << "Number of compressed values" << rlc.count();

The view would only be a forward_iterator container. but since it looks like
a container, you could use std::copy, or std::transform to capture the
output.

(Just an idea...)

And yes I did mean patented...oops.

  -gary-

gary.powell_at_[hidden]


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk