Qucs-core  0.0.18
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ptrlist.h
Go to the documentation of this file.
1 /*
2  * ptrlist.h - pointer list template class definitions
3  *
4  * Copyright (C) 2005, 2006 Stefan Jahn <stefan@lkcc.org>
5  *
6  * This is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2, or (at your option)
9  * any later version.
10  *
11  * This software is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this package; see the file COPYING. If not, write to
18  * the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
19  * Boston, MA 02110-1301, USA.
20  *
21  * $Id$
22  *
23  */
24 
25 #ifndef __PTRLIST_H__
26 #define __PTRLIST_H__
27 
28 namespace qucs {
29 
30 template <class type_t> class ptrentry;
31 template <class type_t> class ptrlist;
32 template <class type_t> class ptrlistiterator;
33 
34 /* Pointer entry class. */
35 template <class type_t>
36 class ptrentry
37 {
38  friend class ptrlist<type_t>;
39  friend class ptrlistiterator<type_t>;
40 
41  public:
42  type_t * data;
43 
44  private:
47 };
48 
49 /* Pointer list class. */
50 template <class type_t>
51 class ptrlist
52 {
53  friend class ptrlistiterator<type_t>;
54 
55  public:
56  ptrlist ();
57  ~ptrlist ();
58  ptrlist (const ptrlist &);
59  void add (type_t *);
60  void append (type_t *);
61  void del (type_t *);
62  int length (void);
63  int contains (type_t *);
64  int index (type_t *);
65  type_t * get (int);
66 
67  private:
68  int size;
69  ptrentry<type_t> * root;
70 };
71 
72 /* Pointer list iterator. */
73 template <class type_t>
74 class ptrlistiterator
75 {
76  public:
77  ptrlistiterator ();
78  ptrlistiterator (ptrlist<type_t> &);
80 
81  int count (void);
82  type_t * toFirst (void);
83  type_t * toLast (void);
84  type_t * operator++ (void);
85  type_t * operator-- (void);
86  type_t * operator * (void) { return current (); }
87  type_t * current (void);
88  type_t * first (void);
89  type_t * last (void);
90 
91  private:
92  ptrlist<type_t> * _ptrlist;
96 };
97 
98 } // namespace qucs
99 
100 #include "ptrlist.cpp"
101 
102 #endif /* __PTRLIST_H__ */
type_t * current(void)
Definition: ptrlist.cpp:210
type_t * first(void)
Definition: ptrlist.cpp:216
type_t * operator++(void)
Definition: ptrlist.cpp:196
void add(type_t *)
Definition: ptrlist.cpp:69
ptrentry< type_t > * _last
Definition: ptrlist.h:94
int index(type_t *)
Definition: ptrlist.cpp:137
ptrentry< type_t > * _first
Definition: ptrlist.h:93
int contains(type_t *)
Definition: ptrlist.cpp:127
ptrlist< type_t > * _ptrlist
Definition: ptrlist.h:92
ptrentry * prev
Definition: ptrlist.h:46
ptrentry< type_t > * root
Definition: ptrlist.h:69
type_t * toLast(void)
Definition: ptrlist.cpp:188
void append(type_t *)
Definition: ptrlist.cpp:81
void del(type_t *)
Definition: ptrlist.cpp:106
ptrentry * next
Definition: ptrlist.h:45
int length(void)
Definition: ptrlist.cpp:100
ptrentry< type_t > * _current
Definition: ptrlist.h:95
List int
Definition: parse_citi.y:183
type_t * operator--(void)
Definition: ptrlist.cpp:203
type_t * operator*(void)
Definition: ptrlist.h:86
type_t * last(void)
Definition: ptrlist.cpp:222
type_t * data
Definition: ptrlist.h:42
type_t * toFirst(void)
Definition: ptrlist.cpp:181