Laxkit  0.0.7.1
linkedlist.h
1 //
2 //
3 // The Laxkit, a windowing toolkit
4 // Please consult http://laxkit.sourceforge.net about where to send any
5 // correspondence about this software.
6 //
7 // This library is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU Library General Public
9 // License as published by the Free Software Foundation; either
10 // version 2 of the License, or (at your option) any later version.
11 //
12 // This library is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 // Library General Public License for more details.
16 //
17 // You should have received a copy of the GNU Library General Public
18 // License along with this library; if not, write to the Free Software
19 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 //
21 // Copyright (C) 2004-2007 by Tom Lechner
22 //
23 #ifndef _LAX_LINKEDLIST_H
24 #define _LAX_LINKEDLIST_H
25 
26 namespace Laxkit {
27 
28 #ifndef NULL
29 #define NULL 0
30 #endif
31 
32 
33 //-------------------------- LinkedList -----------------------------
34 template <class T>
36 {
37  protected:
38  T *next_node,*prev_node;
39  public:
40  LinkedList();
41  virtual ~LinkedList();
42  virtual T *disconnectNode();
43  virtual int connectNode(T *node);
44  virtual int closeNodeLoop();
45  virtual T *openNodeLoop(int before);
46 };
47 
48 //-------------------------------------- PtrList -----------------------------------
49 template <class T>
50 class PtrList
51 {
52  protected:
53  int num;
54  struct node
55  { T *data;
56  char dataislocal;
57  node *next,*prev;
58  node() { next=prev=NULL; data=NULL; dataislocal=0; }
59  node(T *nd, char istobelocal) {next=prev=NULL; data=nd; dataislocal=istobelocal; }
60  ~node();
61  } *first;
62  public:
63  PtrList() { num=0; first=NULL; }
64  virtual ~PtrList();
65 // T &operator[](int n);
66  virtual void flush();
67  virtual int howmany() { return num; }
68  virtual int push(T *nd,char local=1,int where=-1);
69  virtual int pop(T *&popped,int which=-1,char *local=NULL);
70  virtual T *pop(int which=-1); // -1 means from the end, <-1 means return NULL
71  virtual int findindex(T *t);
72  virtual int remove(int which=-1); // which is index
73  virtual int pushnodup(T *nd,char local); // push on end, returns 1 if pushed
74 };
75 
76 
77 
78 
79 #ifndef LAX_DONT_INCLUDE_LINKEDLIST_CC
80 #include <lax/linkedlist.cc>
81 #endif
82 
83 } // namespace Laxkit;
84 
85 #endif
86 

Mon Feb 17 2014 11:52:57, Laxkit