Scroll to navigation

pair_set(7rheolef) rheolef-7.0 pair_set(7rheolef)

NAME

pair_set - a set of (index,value) pair (rheolef-7.0)

SYNOPSIS

A class for: l = {(0,3.3),...(7,8.2)} i.e. a wrapper for STL map<size_t,T> with some assignment operators, such as l1 += l2. This class is suitable for use with the disarray<T> class, as disarray<pair_set> (see disarray(2)).

TODO

template <T,A> with A=std::allocator or heap_allocator difficulty: get heap_allocator<T> or std::allocator<T> and then requires heap_allocator<pair<size_t,T>> or std::allocator<>pair<size_t,T>> for std::map

IMPLEMENTATION

template<class T, class A = std::allocator<std::pair<std::size_t,T> > >
class pair_set: public std::map<std::size_t, T, std::less<std::size_t> > {

// TODO: use A extra-arg for std::map for heap_allocator public: // typedefs:
typedef std::size_t size_type;
typedef std::pair<size_type,T> pair_type;
typedef std::pair<const size_type,T> const_pair_type;
typedef pair_type value_type;
typedef std::map<size_type, T, std::less<size_type> > // TODO: use allocator_type for heap_allocator
base; #ifdef TODO
typedef typename base::allocator_type allocator_type; #endif // TODO
typedef A allocator_type;
typedef typename base::iterator iterator;
typedef typename base::const_iterator const_iterator; // allocators:
pair_set (const A& alloc = A());
pair_set (const pair_set<T,A>& x, const A& alloc = A());
pair_set<T,A>& operator= (const pair_set<T,A>& x);
void clear (); // basic algebra: semantic of a sparse vector
pair_set<T,A>& operator+= (const pair_type& x); // c := a union {x}
template<class B>
pair_set<T,A>& operator+= (const pair_set<T,B>& b); // c := a union b // boost mpi:
template <class Archive>
void serialize (Archive& ar, const unsigned int version); }; // io: template <class T, class A> std::istream& operator>> (std::istream& is, pair_set<T,A>& a); template <class T, class A> std::ostream& operator<< (std::ostream& os, const pair_set<T,A>& b);

SEE ALSO

disarray(2)

COPYRIGHT

Copyright (C) 2000-2018 Pierre Saramito <Pierre.Saramito@imag.fr> GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>. This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.

rheolef-7.0 rheolef-7.0