libzypp  13.10.6
Queue.h
Go to the documentation of this file.
1 /*---------------------------------------------------------------------\
2 | ____ _ __ __ ___ |
3 | |__ / \ / / . \ . \ |
4 | / / \ V /| _/ _/ |
5 | / /__ | | | | | | |
6 | /_____||_| |_| |_| |
7 | |
8 \---------------------------------------------------------------------*/
11 #ifndef ZYPP_SAT_QUEUE_H
12 #define ZYPP_SAT_QUEUE_H
13 
14 extern "C"
15 {
16  struct _Queue;
17 }
18 #include <iosfwd>
19 
20 #include "zypp/base/NonCopyable.h"
22 
24 namespace zypp
25 {
26  namespace sat
28  {
29 
32  class Queue : private base::NonCopyable
33  {
34  public:
35  typedef unsigned size_type;
37  typedef const value_type* const_iterator;
38 
39  public:
41  Queue();
42 
44  ~Queue();
45 
46  bool empty() const;
47  size_type size() const;
48  const_iterator begin() const;
49  const_iterator end() const;
50 
52  const_iterator find( value_type val_r ) const;
53 
55  bool contains( value_type val_r ) const
56  { return( find( val_r ) != end() ); }
57 
59  value_type first() const;
60 
62  value_type last() const;
63 
65  void clear();
66 
68  void remove( value_type val_r );
69 
71  void push( value_type val_r );
73  void push_back( value_type val_r )
74  { push( val_r ); }
75 
77  value_type pop();
80  { return pop(); }
81 
83  void push_front( value_type val_r );
84 
87 
88  public:
90  operator struct ::_Queue *()
91  { return _pimpl; }
93  operator const struct ::_Queue *() const
94  { return _pimpl; }
95 
96  private:
98  struct ::_Queue * _pimpl;
99  };
100 
102  std::ostream & operator<<( std::ostream & str, const Queue & obj );
103 
105  std::ostream & dumpOn( std::ostream & str, const Queue & obj );
106 
108  bool operator==( const Queue & lhs, const Queue & rhs );
109 
111  inline bool operator!=( const Queue & lhs, const Queue & rhs )
112  { return !( lhs == rhs ); }
113 
115  } // namespace sat
118 } // namespace zypp
120 #endif // ZYPP_SAT_QUEUE_H
int IdType
Generic Id type.
Definition: PoolMember.h:82
std::ostream & operator<<(std::ostream &str, const LocaleSupport &obj)
detail::IdType value_type
Definition: Queue.h:36
value_type pop_back()
Definition: Queue.h:79
bool operator==(const Map &lhs, const Map &rhs)
Definition: Map.cc:118
struct::_Queue * _pimpl
Pointer to implementation.
Definition: Queue.h:98
value_type last() const
Return the last Id in the queue or 0 if empty.
Definition: Queue.cc:69
const_iterator find(value_type val_r) const
Return iterator to the 1st occurance of val_r or end.
Definition: Queue.cc:54
const_iterator end() const
Definition: Queue.cc:51
void push(value_type val_r)
Push a value to the end off the Queue.
Definition: Queue.cc:88
boost::noncopyable NonCopyable
Ensure derived classes cannot be copied.
Definition: NonCopyable.h:26
const_iterator begin() const
Definition: Queue.cc:48
value_type pop_front()
Pop and return the 1st Id from the queue or 0 if empty.
Definition: Queue.cc:97
unsigned size_type
Definition: Queue.h:35
void push_front(value_type val_r)
Push a value to the beginning off the Queue.
Definition: Queue.cc:94
const value_type * const_iterator
Definition: Queue.h:37
std::ostream & dumpOn(std::ostream &str, const LocaleSupport &obj)
void push_back(value_type val_r)
Definition: Queue.h:73
Libsolv Id queue wrapper.
Definition: Queue.h:32
void clear()
Clear the queue.
Definition: Queue.cc:76
bool operator!=(const Queue &lhs, const Queue &rhs)
Definition: Queue.h:111
size_type size() const
Definition: Queue.cc:45
Queue()
Default ctor: empty Queue.
Definition: Queue.cc:30
~Queue()
Dtor.
Definition: Queue.cc:36
value_type first() const
Return the 1st Id in the queue or 0 if empty.
Definition: Queue.cc:62
bool empty() const
Definition: Queue.cc:42
value_type pop()
Pop and return the last Id from the queue or 0 if empty.
Definition: Queue.cc:91
bool contains(value_type val_r) const
Return whether the Queue contais at lest one element with value val_r.
Definition: Queue.h:55