xrootd
Main Page
Namespaces
Classes
Files
File List
File Members
src
XrdOuc
XrdOucChain.hh
Go to the documentation of this file.
1
#ifndef __OUC_CHAIN__
2
#define __OUC_CHAIN__
3
/******************************************************************************/
4
/* */
5
/* X r d O u c C h a i n . h h */
6
/* */
7
/* (c) 2003 by the Board of Trustees of the Leland Stanford, Jr., University */
8
/* All Rights Reserved */
9
/* Produced by Andrew Hanushevsky for Stanford University under contract */
10
/* DE-AC03-76-SFO0515 with the Department of Energy */
11
/******************************************************************************/
12
13
// $Id$
14
15
template
<
class
T>
16
class
XrdOucQSItem
17
{
18
public
:
19
XrdOucQSItem<T>
*
nextelem
;
20
T *
dataitem
;
21
XrdOucQSItem
(T *item) {
dataitem
= item;
nextelem
= 0;}
22
~XrdOucQSItem
() {}
23
};
24
25
template
<
class
T>
26
class
XrdOucStack
27
{
28
public
:
29
30
int
isEmpty
() {
return
anchor
== 0;}
31
32
T *
Pop
() {
XrdOucQSItem<T>
*cp;
33
if
(!(cp =
anchor
))
return
(T *)0;
34
anchor
=
anchor
->nextelem;
35
cp->
nextelem
= 0;
36
return
cp->
dataitem
;
37
}
38
39
void
Push
(
XrdOucQSItem<T>
*item) {item->
nextelem
=
anchor
;
anchor
= item;}
40
41
XrdOucStack
() {
anchor
= 0;}
42
~XrdOucStack
() {}
43
44
private
:
45
XrdOucQSItem<T>
*
anchor
;
46
};
47
48
template
<
class
T>
49
class
XrdOucQueue
50
{
51
public
:
52
53
void
Add
(
XrdOucQSItem<T>
*item)
54
{item->
nextelem
= 0;
55
if
(
lastelem
) {
lastelem
->nextelem = item;
56
lastelem
= item;
57
}
58
else
anchor
=
lastelem
= item;
59
}
60
61
int
isEmpty
() {
return
anchor
== 0;}
62
63
T *
Remove
() {
XrdOucQSItem<T>
*qp;
64
if
(!(qp =
anchor
))
return
(T *)0;
65
if
(!(
anchor
=
anchor
->nextelem))
lastelem
= 0;
66
return
qp->
dataitem
;
67
}
68
69
XrdOucQueue
() {
anchor
=
lastelem
= 0;}
70
~XrdOucQueue
() {}
71
72
private
:
73
XrdOucQSItem<T>
*
anchor
;
74
XrdOucQSItem<T>
*
lastelem
;
75
};
76
#endif
Generated by
1.8.1.2