Boost logo

Boost :

From: Rozental, Gennadiy (Gennadiy_at_[hidden])
Date: 2002-09-09 12:08:23


> I've been working on the interface and come up with something
> I'm pretty
> happy with. The name still needs thrashing out, and I expect
> to have some
> further constructive discussion on this in the future. But
> for now, what
> would you say to an interface along these lines? Note that this is an
> abstract of the full interface omitting the change list
> details.(sorry about
> the formatting!)
>
> namespace boost {
>
> template <typename Seq>
> class longest_common_subsequence : noncopyable
> {
> public:
> // list of changes made to sequence1 to create sequence2
> typedef ... change_set;
>
> public:
> longest_common_subsequence(const Seq &first, const Seq &second);
> // note there's also a ctor taking const_iterator pairs for
> // the first and second seq
>
> unsigned compute_lcs( unsigned mask,
> longest_common_subsequence<Seq>::change_set *changes);
>
> bool reconstruct_sequence( const
> longest_common_subsequence<Seq>::change_set &changes,
> const Seq &original,
> Seq *reconstructed);
> };
>
> // namespace boost

In most part I disagree with what you proposing here.

1. These are two different algorithms and no need to mix them.
2. What is change_set is it some special type?
3. STL algorithms are iterator based, not sequence based. WE should keep it
that way
4. Why are you using pointers and not a references?
5. How could I obtain changes to pass as a first argument ot second
algorithm if you don't return them?
6. Why do e need class at all?

Here how I invision it

template<typename InIt1, typename InIt2, typename OutIt >
void
longest_common_subsequence( InIt1 first_begin, InIt1 first_end,
                                                InIt2 second_begin,
                                                OutIt& res_begin );

template<typename InIt, typename DiffIt, typename OutIt >
void
apply_diff( InIt input_begin, InIt input_end, InIt diff_begin, OutIt
res_begin );

Gennadiy.


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