Eneboo - Documentación para desarrolladores
src/hoard/src/heaplayers/util/dllist.h
Ir a la documentación de este archivo.
00001 // -*- C++ -*-
00002 
00003 /*
00004 
00005   Heap Layers: An Extensible Memory Allocation Infrastructure
00006   
00007   Copyright (C) 2000-2003 by Emery Berger
00008   http://www.cs.umass.edu/~emery
00009   emery@cs.umass.edu
00010   
00011   This program is free software; you can redistribute it and/or modify
00012   it under the terms of the GNU General Public License as published by
00013   the Free Software Foundation; either version 2 of the License, or
00014   (at your option) any later version.
00015   
00016   This program is distributed in the hope that it will be useful,
00017   but WITHOUT ANY WARRANTY; without even the implied warranty of
00018   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019   GNU General Public License for more details.
00020   
00021   You should have received a copy of the GNU General Public License
00022   along with this program; if not, write to the Free Software
00023   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00024 
00025 */
00026 
00027 #ifndef _DLLIST_H_
00028 #define _DLLIST_H_
00029 
00030 #include <assert.h>
00031 
00039 namespace HL {
00040 
00041 class DLList {
00042 public:
00043 
00044   inline DLList (void) {
00045     clear();
00046   }
00047 
00048   class Entry;
00049   
00051   inline void clear (void) {
00052     head.setPrev (&head);
00053     head.setNext (&head);
00054   }
00055 
00057   inline bool isEmpty (void) const {
00058     return (head.getNext() == &head);
00059   }
00060 
00062   inline Entry * get (void) {
00063     const Entry * e = head.next;
00064     if (e == &head) {
00065       return NULL;
00066     }
00067     head.next = e->next;
00068     head.next->prev = &head;
00069     return (Entry *) e;
00070   }
00071 
00073   inline void remove (Entry * e) {
00074     e->remove();
00075   }
00076 
00078   inline void insert (Entry * e) {
00079     e->insert (&head, head.next);
00080   }
00081 
00083   class Entry {
00084   public:
00085     //  private:
00086     inline void setPrev (Entry * p) { assert (p != NULL); prev = p; }
00087     inline void setNext (Entry * p) { assert (p != NULL); next = p; }
00088     inline Entry * getPrev (void) const { return prev; }
00089     inline Entry * getNext (void) const { return next; }
00090     inline void remove (void) const {
00091       prev->setNext(next);
00092       next->setPrev(prev);
00093     }
00094     inline void insert (Entry * p, Entry * n) {
00095       prev = p;
00096       next = n;
00097       p->setNext (this);
00098       n->setPrev (this);
00099     }
00100     Entry * prev;
00101     Entry * next;
00102   };
00103 
00104 
00105 private:
00106 
00108   Entry head;
00109 
00110 };
00111 
00112 }
00113 
00114 #endif
 Todo Clases Namespaces Archivos Funciones Variables 'typedefs' Enumeraciones Valores de enumeraciones Propiedades Amigas 'defines'