Boost logo

Boost :

From: Vladimir Prus (ghost_at_[hidden])
Date: 2001-07-25 11:11:51


On Wednesday 25 July 2001 19:39, darylew_at_[hidden] wrote:

> It is the start of an algorithm collection. It currently has a
> double-bounded mismatch and swap. There's no docs right
> now.

Interesting! Is boost algorithms library going to be created? Then I have
some suggestions based on two files without which I write nothing for the
last year or so.

1. Would it make sense to make versions of all the algorithms working on
containers, not iterators pair. Possible ways:
        - use 'iseq' function:
                sort(iseq(b, e))
        (Suggestion from TC++PL)
        - use similar names
                sort_c(v);
        - use the same names.
                sort(v).
        Having no language support for concepts, some functions will ambiguate
        existing and explicit qualification will be needed. However, I use this
        approach for about year and don't find many inconveniences.

2. There's a lot of functions that I have found usefull. Are they of interest
to others? (Template head omitted in prototypes, some type are given for
illustraction only and should be replaced with more complex expressions)

        bool exists(Container&, Predicate);
        bool any(Container&, Predicate);
        bool exists_and_only(--//--);
        bool contains(Container&, const T&);
        void append(Container1&, Container2&);
        void erase(Container&, const T&); // note 1
        void remove_and_erase(Container&, const T&);
        void remove_and_erase_if(--//--);
        void remove_and_erase_indices(Container&, Predicate);

        // For sorted
        void unique_and_erase(Container&);
        void make_set(Container&);

        // For indexed
        int find_index(Container&, const T&);
        int find_index_if(Container&, Predicate);
        vector<typename Container::iterator>
        find_all_if(Container&, Predicate);
        vector<int>
        find_all_indices_if(Container&, Predicate);
        int min_element_index(Container&);
        int max_element_index(Container&);
        void reorder(Container&, vector<int>& order);
        void reorder_bwd(Container&, vector<int>& order); // note 2

        // For maps
        set<???> domain(Container&);
        set<???> range(Container&);
        
        note 1: probably redundant
        note 2: differs from reorder in the way element of order parameter are
        imterpreted.
                                

-- 
Regards,
Vladimir

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