source: golgotha/src/i4/inc/ref_que.hh @ 80

Last change on this file since 80 was 80, checked in by Sam Hocevar, 14 years ago
  • Adding the Golgotha source code. Not sure what's going to be interesting in there, but since it's all public domain, there's certainly stuff to pick up.
File size: 1.2 KB
Line 
1/********************************************************************** <BR>
2  This file is part of Crack dot Com's free source code release of
3  Golgotha. <a href="http://www.crack.com/golgotha_release"> <BR> for
4  information about compiling & licensing issues visit this URL</a>
5  <PRE> If that doesn't help, contact Jonathan Clark at
6  golgotha_source@usa.net (Subject should have "GOLG" in it)
7***********************************************************************/
8
9#ifndef __REF_QUE_HPP_
10#define __REF_QUE_HPP_
11
12template <class T>
13class i4_reference_que_class
14{
15  class node
16  {
17    friend class i4_reference_que_class<T>;
18    T    *reference;
19    node *last;
20    public :
21    node(T *ref, node *last) : reference(ref), last(last) {}
22  } *first,*last;
23
24  public :
25  i4_reference_que_class()
26  {
27    first=last=0;
28  }
29
30  void enque(T *reference)
31  {
32    first=new node(reference,first);
33    if (!last)
34      last=first;
35  }
36
37  T *deque()
38  {
39    if (!last)       
40      return 0;
41    else
42    {
43      node *del=last;
44      T    *p  =last->reference;
45      last=last->last;
46      delete del;
47      if (!last)
48        first=0;
49     
50      return p;
51    }
52  }
53} ;
54
55#endif
Note: See TracBrowser for help on using the repository browser.