libzypp  15.3.0
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/PtrTypes.h"
22 
24 namespace zypp
25 {
27  namespace sat
28  {
29  class Queue;
30  typedef Queue SolvableQueue;
31  typedef Queue StringQueue;
32 
38  class Queue
39  {
40  public:
41  typedef unsigned size_type;
43  typedef const value_type* const_iterator;
44 
45  public:
47  Queue();
48 
50  ~Queue();
51 
52  bool empty() const;
53  size_type size() const;
54  const_iterator begin() const;
55  const_iterator end() const;
56 
58  const_iterator find( value_type val_r ) const;
59 
61  bool contains( value_type val_r ) const
62  { return( find( val_r ) != end() ); }
63 
65  value_type first() const;
66 
68  value_type last() const;
69 
73  const value_type & at( size_type idx_r ) const;
74 
78  value_type & at( size_type idx_r );
79 
81  const value_type & operator[]( size_type idx_r ) const;
82 
84  value_type & operator[]( size_type idx_r );
85 
87  void clear();
88 
90  void remove( value_type val_r );
91 
93  void push( value_type val_r );
95  void push_back( value_type val_r )
96  { push( val_r ); }
97 
99  void pushUnique( value_type val_r );
100 
102  value_type pop();
104  value_type pop_back()
105  { return pop(); }
106 
108  void push_front( value_type val_r );
109 
111  value_type pop_front();
112 
113  public:
114  operator struct ::_Queue *();
115  operator const struct ::_Queue *() const
116  { return _pimpl.get(); }
117  private:
119  };
120 
122  std::ostream & operator<<( std::ostream & str, const Queue & obj );
123 
125  std::ostream & dumpOn( std::ostream & str, const Queue & obj );
126 
128  bool operator==( const Queue & lhs, const Queue & rhs );
129 
131  inline bool operator!=( const Queue & lhs, const Queue & rhs )
132  { return !( lhs == rhs ); }
133 
134  } // namespace sat
136 
138  template<> struct ::_Queue * rwcowClone<struct ::_Queue>( const struct ::_Queue * rhs );
139 
140 } // namespace zypp
142 #endif // ZYPP_SAT_QUEUE_H
int IdType
Generic Id type.
Definition: PoolMember.h:82
detail::IdType value_type
Definition: Queue.h:42
value_type pop_back()
Definition: Queue.h:104
bool operator==(const Map &lhs, const Map &rhs)
Definition: Map.cc:123
Queue SolvableQueue
Queue with Solvable ids.
Definition: Queue.h:29
std::ostream & operator<<(std::ostream &str, const FileConflicts &obj)
value_type last() const
Return the last Id in the queue or 0 if empty.
Definition: Queue.cc:73
String related utilities and Regular expression matching.
const_iterator find(value_type val_r) const
Return iterator to the 1st occurance of val_r or end.
Definition: Queue.cc:58
const_iterator end() const
Definition: Queue.cc:55
Queue StringQueue
Queue with String ids.
Definition: Queue.h:31
void push(value_type val_r)
Push a value to the end off the Queue.
Definition: Queue.cc:103
void pushUnique(value_type val_r)
Push a value if it's not yet in the Queue.
Definition: Queue.cc:106
const _D * get() const
Definition: PtrTypes.h:503
const_iterator begin() const
Definition: Queue.cc:52
value_type pop_front()
Pop and return the 1st Id from the queue or 0 if empty.
Definition: Queue.cc:115
unsigned size_type
Definition: Queue.h:41
void push_front(value_type val_r)
Push a value to the beginning off the Queue.
Definition: Queue.cc:112
RWCOW_pointer< struct::_Queue > _pimpl
Pointer to implementation.
Definition: Queue.h:118
const value_type * const_iterator
Definition: Queue.h:43
std::ostream & dumpOn(std::ostream &str, const LocaleSupport &obj)
void push_back(value_type val_r)
Definition: Queue.h:95
const value_type & at(size_type idx_r) const
Return the Id at idx_r in the queue.
Definition: Queue.cc:82
Libsolv Id queue wrapper.
Definition: Queue.h:38
void clear()
Clear the queue.
Definition: Queue.cc:94
const value_type & operator[](size_type idx_r) const
Return the Id at idx_r in the queue (no range check)
Definition: Queue.cc:88
bool operator!=(const Queue &lhs, const Queue &rhs)
Definition: Queue.h:131
size_type size() const
Definition: Queue.cc:49
Queue()
Default ctor: empty Queue.
Definition: Queue.cc:39
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:1
~Queue()
Dtor.
Definition: Queue.cc:43
value_type first() const
Return the 1st Id in the queue or 0 if empty.
Definition: Queue.cc:66
bool empty() const
Definition: Queue.cc:46
value_type pop()
Pop and return the last Id from the queue or 0 if empty.
Definition: Queue.cc:109
bool contains(value_type val_r) const
Return whether the Queue contais at lest one element with value val_r.
Definition: Queue.h:61