00001 /* 00002 from Unidraw but UList changed to HTList (head tail list) 00003 for fast insertion, deletion, iteration 00004 */ 00005 00006 /* 00007 * Copyright (c) 1990, 1991 Stanford University 00008 * 00009 * Permission to use, copy, modify, distribute, and sell this software and its 00010 * documentation for any purpose is hereby granted without fee, provided 00011 * that the above copyright notice appear in all copies and that both that 00012 * copyright notice and this permission notice appear in supporting 00013 * documentation, and that the name of Stanford not be used in advertising or 00014 * publicity pertaining to distribution of the software without specific, 00015 * written prior permission. Stanford makes no representations about 00016 * the suitability of this software for any purpose. It is provided "as is" 00017 * without express or implied warranty. 00018 * 00019 * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, 00020 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. 00021 * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR 00022 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, 00023 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR 00024 * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION 00025 * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 00026 */ 00027 00028 /* 00029 * UList - list object. 00030 */ 00031 00032 #ifndef htlist_h 00033 #define htlist_h 00034 00035 class HTList { 00036 public: 00037 HTList(void* = nil); 00038 virtual ~HTList(); 00039 00040 boolean IsEmpty(); 00041 void Append(HTList*); 00042 void Prepend(HTList*); 00043 void Remove(HTList*); 00044 void Remove(); 00045 void RemoveAll(); 00046 void Delete(void*); 00047 HTList* Find(void*); 00048 HTList* First(); 00049 HTList* Last(); 00050 HTList* End(); 00051 HTList* Next(); 00052 HTList* Prev(); 00053 00054 void* vptr(); 00055 void* operator()(); 00056 HTList* operator[](int count); 00057 protected: 00058 void* _object; 00059 HTList* _next; 00060 HTList* _prev; 00061 }; 00062 00063 inline boolean HTList::IsEmpty () { return _next == this; } 00064 inline HTList* HTList::First () { return _next; } 00065 inline HTList* HTList::Last () { return _prev; } 00066 inline HTList* HTList::End () { return this; } 00067 inline HTList* HTList::Next () { return _next; } 00068 inline HTList* HTList::Prev () { return _prev; } 00069 inline void* HTList::operator() () { return _object; } 00070 inline void* HTList::vptr() { return _object; } 00071 #endif