NEURON
htlist.h
Go to the documentation of this file.
1 /*
2 from Unidraw but UList changed to HTList (head tail list)
3 for fast insertion, deletion, iteration
4 */
5 
6 /*
7  * Copyright (c) 1990, 1991 Stanford University
8  *
9  * Permission to use, copy, modify, distribute, and sell this software and its
10  * documentation for any purpose is hereby granted without fee, provided
11  * that the above copyright notice appear in all copies and that both that
12  * copyright notice and this permission notice appear in supporting
13  * documentation, and that the name of Stanford not be used in advertising or
14  * publicity pertaining to distribution of the software without specific,
15  * written prior permission. Stanford makes no representations about
16  * the suitability of this software for any purpose. It is provided "as is"
17  * without express or implied warranty.
18  *
19  * STANFORD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
20  * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
21  * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
22  * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
23  * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
24  * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
25  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
26  */
27 
28 /*
29  * UList - list object.
30  */
31 
32 #pragma once
33 
34 class HTList {
35  public:
36  HTList(void* = NULL);
37  virtual ~HTList();
38 
39  bool IsEmpty();
40  void Append(HTList*);
41  void Prepend(HTList*);
42  void Remove(HTList*);
43  void Remove();
44  void RemoveAll();
45  void Delete(void*);
46  HTList* Find(void*);
47  HTList* First();
48  HTList* Last();
49  HTList* End();
50  HTList* Next();
51  HTList* Prev();
52 
53  void* vptr();
54  void* operator()();
55  HTList* operator[](int count);
56 
57  protected:
58  void* _object;
61 };
62 
63 inline bool HTList::IsEmpty() {
64  return _next == this;
65 }
66 inline HTList* HTList::First() {
67  return _next;
68 }
69 inline HTList* HTList::Last() {
70  return _prev;
71 }
72 inline HTList* HTList::End() {
73  return this;
74 }
75 inline HTList* HTList::Next() {
76  return _next;
77 }
78 inline HTList* HTList::Prev() {
79  return _prev;
80 }
81 inline void* HTList::operator()() {
82  return _object;
83 }
84 inline void* HTList::vptr() {
85  return _object;
86 }
Definition: htlist.h:34
void Remove()
Definition: htlist.cpp:75
HTList * Find(void *)
Definition: htlist.cpp:99
void * _object
Definition: htlist.h:58
void Prepend(HTList *)
Definition: htlist.cpp:62
HTList * Prev()
Definition: htlist.h:78
bool IsEmpty()
Definition: htlist.h:63
void * vptr()
Definition: htlist.h:84
HTList * Last()
Definition: htlist.h:69
HTList * First()
Definition: htlist.h:66
void * operator()()
Definition: htlist.h:81
virtual ~HTList()
Definition: htlist.cpp:47
HTList * Next()
Definition: htlist.h:75
HTList(void *=NULL)
Definition: htlist.cpp:41
void Append(HTList *)
Definition: htlist.cpp:55
HTList * _next
Definition: htlist.h:59
HTList * _prev
Definition: htlist.h:60
HTList * operator[](int count)
Definition: htlist.cpp:110
HTList * End()
Definition: htlist.h:72
void RemoveAll()
Definition: htlist.cpp:84
void Delete(void *)
Definition: htlist.cpp:89
#define NULL
Definition: spdefs.h:105