---
name: "pair_set"
section: "7rheolef"
platform: "linux"
package: "librheolef-dev"
version: "7.0-2+b1"
release: "Debian 10 (Buster)"
platforms: ["linux"]
url: "https://new.carta.tech/pair_set"
---

# pair\_set(7rheolef)

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

## 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.
