libzypp  17.38.7
queue.h
Go to the documentation of this file.
1 /*---------------------------------------------------------------------\
2 | ____ _ __ __ ___ |
3 | |__ / \ / / . \ . \ |
4 | / / \ V /| _/ _/ |
5 | / /__ | | | | | | |
6 | /_____||_| |_| |_| |
7 | |
8 \---------------------------------------------------------------------*/
11 #ifndef ZYPP_NG_SAT_QUEUE_H
12 #define ZYPP_NG_SAT_QUEUE_H
13 
14 #include <iosfwd>
15 
16 #include <zypp-core/Globals.h>
18 
20 
22 namespace zyppng
23 {
25  namespace sat
26  {
27  class Queue;
28  using SolvableQueue = Queue;
29  using StringQueue = Queue;
30 
36  class Queue
37  {
38  public:
39  using size_type = unsigned int;
41  using const_iterator = const value_type *;
42 
43  public:
45  Queue();
46 
48  ~Queue();
49 
50  bool empty() const;
51  size_type size() const;
52  const_iterator begin() const;
53  const_iterator end() const;
54 
56  const_iterator find( value_type val_r ) const;
57 
59  bool contains( value_type val_r ) const
60  { return( find( val_r ) != end() ); }
61 
63  value_type first() const;
64 
66  value_type last() const;
67 
71  const value_type & at( size_type idx_r ) const;
72 
76  value_type & at( size_type idx_r );
77 
79  const value_type & operator[]( size_type idx_r ) const;
80 
82  value_type & operator[]( size_type idx_r );
83 
85  void clear();
86 
88  void remove( value_type val_r );
89 
91  void push( value_type val_r );
93  void push_back( value_type val_r )
94  { push( val_r ); }
95 
97  void pushUnique( value_type val_r );
98 
100  value_type pop();
103  { return pop(); }
104 
106  void push_front( value_type val_r );
107 
110 
111  public:
112  operator detail::CQueue *();
113  operator const detail::CQueue *() const
114  { return _pimpl.get(); }
115  private:
117  };
118 
120  bool operator==( const Queue & lhs, const Queue & rhs );
121 
123  inline bool operator!=( const Queue & lhs, const Queue & rhs )
124  { return !( lhs == rhs ); }
125 
126  } // namespace sat
128 } // namespace zyppng
129 
130 namespace zypp {
132  template<> sat::detail::CQueue * rwcowClone<sat::detail::CQueue>( const sat::detail::CQueue * rhs );
133 }
134 
135 
137 #endif // ZYPP_NG_SAT_QUEUE_H
unsigned int size_type
Definition: queue.h:39
~Queue()
Dtor.
Definition: queue.cc:49
bool operator==(const Capability &lhs, const Capability &rhs)
relates: Capability
Definition: capability.h:311
bool empty() const
Definition: queue.cc:52
value_type first() const
Return the 1st Id in the queue or 0 if empty.
Definition: queue.cc:72
detail::IdType value_type
Definition: queue.h:40
zypp::sat::detail::CQueue CQueue
Definition: poolconstants.h:37
Queue()
Default ctor: empty Queue.
Definition: queue.cc:45
const value_type & operator[](size_type idx_r) const
Return the Id at idx_r in the queue (no range check)
Definition: queue.cc:94
const value_type * const_iterator
Definition: queue.h:41
size_type size() const
Definition: queue.cc:55
const value_type & at(size_type idx_r) const
Return the Id at idx_r in the queue.
Definition: queue.cc:88
value_type pop()
Pop and return the last Id from the queue or 0 if empty.
Definition: queue.cc:115
Provides API related macros.
void pushUnique(value_type val_r)
Push a value if it&#39;s not yet in the Queue.
Definition: queue.cc:112
void push(value_type val_r)
Push a value to the end off the Queue.
Definition: queue.cc:109
const_iterator begin() const
Definition: queue.cc:58
zypp::sat::detail::IdType IdType
Definition: poolconstants.h:43
bool operator!=(const Capability &lhs, const Capability &rhs)
relates: Capability
Definition: capability.h:315
value_type pop_front()
Pop and return the 1st Id from the queue or 0 if empty.
Definition: queue.cc:121
value_type last() const
Return the last Id in the queue or 0 if empty.
Definition: queue.cc:79
Libsolv Id queue wrapper.
Definition: queue.h:36
void push_front(value_type val_r)
Push a value to the beginning off the Queue.
Definition: queue.cc:118
const_iterator end() const
Definition: queue.cc:61
value_type pop_back()
Definition: queue.h:102
const D * get() const
Definition: PtrTypes.h:519
::s_Queue CQueue
Wrapped libsolv C data type exposed as backdoor.
Definition: PoolDefines.h:35
const_iterator find(value_type val_r) const
Return iterator to the 1st occurance of val_r or end.
Definition: queue.cc:64
void clear()
Clear the queue.
Definition: queue.cc:100
Easy-to use interface to the ZYPP dependency resolver.
Definition: CodePitfalls.doc:1
bool contains(value_type val_r) const
Return whether the Queue contais at lest one element with value val_r.
Definition: queue.h:59
void push_back(value_type val_r)
Definition: queue.h:93
zypp::RWCOW_pointer< zypp::sat::detail::CQueue > _pimpl
Pointer to implementation.
Definition: queue.h:116