libzypp
12.16.5
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
Queue.cc
Go to the documentation of this file.
1
/*---------------------------------------------------------------------\
2
| ____ _ __ __ ___ |
3
| |__ / \ / / . \ . \ |
4
| / / \ V /| _/ _/ |
5
| / /__ | | | | | | |
6
| /_____||_| |_| |_| |
7
| |
8
\---------------------------------------------------------------------*/
11
extern
"C"
12
{
13
#include <solv/queue.h>
14
}
15
#include <iostream>
16
#include "
zypp/base/LogTools.h
"
17
18
#include "
zypp/sat/Queue.h
"
19
#include "
zypp/sat/Solvable.h
"
20
21
using
std::endl;
22
24
namespace
zypp
25
{
26
27
namespace
sat
28
{
29
30
Queue::Queue
()
31
: _pimpl( new struct ::_Queue )
32
{
33
::queue_init(
_pimpl
);
34
}
35
36
Queue::~Queue
()
37
{
38
::queue_free(
_pimpl
);
39
delete
(
_pimpl
);
40
}
41
42
bool
Queue::empty
()
const
43
{
return
(
_pimpl
->count == 0 ); }
44
45
Queue::size_type
Queue::size
()
const
46
{
return
_pimpl
->count; }
47
48
Queue::const_iterator
Queue::begin
()
const
49
{
return
_pimpl
->elements; }
50
51
Queue::const_iterator
Queue::end
()
const
52
{
return
_pimpl
->elements +
_pimpl
->count;}
53
54
Queue::const_iterator
Queue::find
(
value_type
val_r )
const
55
{
56
for_
( it,
begin
(),
end
() )
57
if
( *it != val_r )
58
return
it;
59
return
end
();
60
}
61
62
Queue::value_type
Queue::first
()
const
63
{
64
if
(
empty
() )
65
return
0;
66
return
*
_pimpl
->elements;
67
}
68
69
Queue::value_type
Queue::last
()
const
70
{
71
if
(
empty
() )
72
return
0;
73
return
_pimpl
->elements[
_pimpl
->count-1];
74
}
75
76
void
Queue::clear
()
77
{ ::queue_empty( *
this
); }
78
79
void
Queue::remove
(
value_type
val_r )
80
{
81
const_iterator
it(
find
( val_r ) );
82
if
( it !=
end
() )
83
{
84
::queue_delete(
_pimpl
, it -
begin
() );
85
}
86
}
87
88
void
Queue::push
(
value_type
val_r )
89
{ ::queue_push(
_pimpl
, val_r ); }
90
91
Queue::value_type
Queue::pop
()
92
{ return ::queue_pop(
_pimpl
); }
93
94
void
Queue::push_front
(
value_type
val_r )
95
{ ::queue_unshift(
_pimpl
, val_r ); }
96
97
Queue::value_type
Queue::pop_front
()
98
{ return ::queue_shift(
_pimpl
); }
99
100
std::ostream &
operator<<
( std::ostream & str,
const
Queue
& obj )
101
{
return
dumpRangeLine
( str <<
"Queue "
, obj.
begin
(), obj.
end
() ); }
102
103
std::ostream &
dumpOn
( std::ostream & str,
const
Queue
& obj )
104
{
105
str <<
"Queue {"
;
106
if
( ! obj.
empty
() )
107
{
108
str << endl;
109
for_
( it, obj.
begin
(), obj.
end
() )
110
str <<
" "
<<
Solvable
(*it) << endl;
111
}
112
return
str <<
"}"
;
113
}
114
115
bool
operator==
(
const
Queue
& lhs,
const
Queue
& rhs )
116
{
117
const
struct ::_Queue * l = lhs;
118
const
struct ::_Queue * r = rhs;
119
return
( l == r || ( l->count == r->count && ::memcmp( l->elements, r->elements, l->count ) == 0 ) );
120
}
121
123
}
// namespace sat
126
}
// namespace zypp
zypp
sat
Queue.cc
Generated by
1.8.2