xrootd
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>
17 {
18 public:
21  XrdOucQSItem(T *item) {dataitem = item; nextelem = 0;}
23 };
24 
25 template<class T>
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 
43 
44 private:
46 };
47 
48 template<class T>
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 
64  if (!(qp = anchor)) return (T *)0;
65  if (!(anchor = anchor->nextelem)) lastelem = 0;
66  return qp->dataitem;
67  }
68 
71 
72 private:
75 };
76 #endif