File: nodes.h

package info (click to toggle)
miwm 1.1-6
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid, stretch
  • size: 1,296 kB
  • ctags: 910
  • sloc: cpp: 8,179; sh: 231; makefile: 148
file content (122 lines) | stat: -rw-r--r-- 3,094 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
//-*-c++-*-
// ------------------------------------------
// RCS data:
// $Date: 2003/06/23 14:47:23 $
// $Revision: 1.1.1.1 $
// $Source: /cvsroot/miwm/miwm/miwm/nodes.h,v $
// $Id: nodes.h,v 1.1.1.1 2003/06/23 14:47:23 bwise837 Exp $
// $RCSfile: nodes.h,v $
// -------------------------------------------
// Copyright by Ben Paul Wise.
// -------------------------------------------
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
// 
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
// 
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
// -------------------------------------------
// handle specialized lists. not suitable
// for generic use.
// -------------------------------------------
//
// notice that we have to be careful with aggregate
// data types like int, float, etc. because the
// pointer-comparision of equivalence will fail
// to find equivalent data. see the demo program.
//
// You also have to be careful in 'delete' of nodes'
// contents that those contents were actually created
// with 'new'. This is a problem in the window manager,
// where X creates the client structures with malloc,
// but then I try to clean up with 'delete'. My 
// memory leak checker catches this subtle error.
//
// ------------------------------------------

#ifndef NODE_LIST_H
#define NODE_LIST_H

#include "alpha.h"
#include <stddef.h>
// #include <assert.h>
// #include <stdio.h>
// #include <iostream.h>

// ------------------------------------------
class NodeList;
class Node;

// delete each node's contents, then delete the list itself (and its nodes)
void obliterateNodeList(NodeList*);

// ------------------------------------------

// clashed with Xlib.h
//
// #ifndef False
// #define False 0
// #endif
// #ifndef True
// #define True (-1)
// #endif


// ------------------------------------------

class Node {
public:
  Node();
  ~Node();

  Node *next;
  Node *prev;
  
  void *data;

protected:
private:
};


// ------------------------------------------

class NodeList {
public:
  NodeList();
  ~NodeList();

  Node *first;
  Node *last;
  Node *actual;


  Node* inList(void* data);
  TLogical prepend(void* data);
  TLogical append(void* data);
  int length();
  Node* at(int i);
  Node* remove(Node* node);
  Node* nextNode(Node* node);
  Node* prevNode(Node* node);

  void moveToEnd(Node* node);
  void moveToFront(Node* node);
protected:
private:
};



// ------------------------------------------
#endif
// ------------------------------------------
// end of nodes.h
// ------------------------------------------