xc
pdeque.h
1 // -*-c++-*-
2 //----------------------------------------------------------------------------
3 // xc utils library; general purpose classes and functions.
4 //
5 // Copyright (C) Luis C. PĂ©rez Tato
6 //
7 // XC utils is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License as published by
9 // the Free Software Foundation, either version 3 of the License, or
10 // (at your option) any later version.
11 //
12 // This software is distributed in the hope that it will be useful, but
13 // WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with this program.
19 // If not, see <http://www.gnu.org/licenses/>.
20 //----------------------------------------------------------------------------
21 //pdeque.h
22 #ifndef PDQUEUE_H
23 #define PDQUEUE_H
24 
25 #include "puntero.h"
26 #include <deque>
27 #include <ostream>
28 
29 template <class N>
30 class pdeque : public std::deque< puntero<N> >
31  {
32  public:
33  typedef std::deque< puntero<N> > deque_pN;
34  typedef typename deque_pN::size_type sz_type;
35  typedef puntero<N> pN;
36 
37  pdeque(void): deque_pN() {}
38  pdeque(sz_type n,const pN &value = pN())
39  :deque_pN(n,value) {}
40  pdeque(const pdeque<N> &otro): deque_pN(otro) {}
41  pdeque<N> &operator =(const pdeque<N> &otro)
42  {
43  deque_pN::operator=(otro);
44  return *this;
45  }
46  void push_back(N *const x)
47  { deque_pN::push_back(pN(x)); }
48  friend bool operator==(const pdeque<N> &pv1,const pdeque<N> &pv2)
49  { return ((const deque_pN &) pv1 == (const deque_pN &)pv2);}
50  };
51 
52 template <class N>
53 std::ostream &operator<<(std::ostream &os,const pdeque<N> &pv)
54  {
55  if(pv.empty())
56  return os;
57  typename pdeque<N>::const_iterator i= pv.begin();
58  os << *i; i++;
59  for(;i!=pv.end();i++)
60  os << ',' << *i;
61  return os;
62  }
63 
64 #endif
65 
Definition: pdeque.h:30
Definition: puntero.h:30