ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Tree-M/GiST/GiSTlist.h
Revision: 1.1
Committed: Sun May 6 00:45:52 2001 UTC (23 years ago) by root
Content type: text/plain
Branch: MAIN
CVS Tags: HEAD
Log Message:
*** empty log message ***

File Contents

# Content
1 // -*- Mode: C++ -*-
2
3 // GiSTlist.h
4 //
5 // Copyright (c) 1996, Regents of the University of California
6 // $Header: /usr/local/devel/GiST/libGiST/libGiST/GiSTlist.h,v 1.1.1.1 1996/08/06 23:47:21 jmh Exp $
7
8 #ifndef GISTLIST_H
9 #define GISTLIST_H
10
11 // A template list package, which is handy.
12 template <class T>
13 struct GiSTlistnode {
14 T entry;
15 GiSTlistnode<T> *prev, *next;
16 };
17
18 template <class T>
19 class GiSTlist {
20 public:
21 GiSTlist() { front=rear=NULL; }
22 // GiSTlist(const GiSTlist<T>& l) { front=l.front; rear=l.rear; }
23 int IsEmpty() { return front==NULL; }
24 T RemoveFront() {
25 assert(front!=NULL);
26 GiSTlistnode<T> *temp=front;
27 T e=front->entry;
28
29 front=front->next;
30 if(front) front->prev=NULL;
31 else rear=NULL;
32 delete temp;
33 return e;
34 }
35
36 T RemoveRear() {
37 assert(rear!=NULL);
38 GiSTlistnode<T> *temp=rear;
39 T e=rear->entry;
40
41 rear=rear->prev;
42 if(rear) rear->next=NULL;
43 else front=NULL;
44 delete temp;
45 return e;
46 }
47
48 void Prepend(T entry) {
49 GiSTlistnode<T> *temp=new GiSTlistnode<T>;
50
51 temp->entry=entry;
52 temp->next=front;
53 temp->prev=NULL;
54 if(rear==NULL) rear=temp;
55 else front->prev=temp;
56 front=temp;
57 }
58
59 void Append(T entry) {
60 GiSTlistnode<T> *temp=new GiSTlistnode<T>;
61
62 temp->entry=entry;
63 temp->prev=rear;
64 temp->next=NULL;
65 if(front==NULL) front=temp;
66 else rear->next=temp;
67 rear=temp;
68 }
69
70 //private:
71 GiSTlistnode<T> *front, *rear;
72 };
73
74 #endif