~ubuntu-branches/ubuntu/quantal/texmacs/quantal

« back to all changes in this revision

Viewing changes to src/Classes/Compound/list.hpp

  • Committer: Bazaar Package Importer
  • Author(s): Atsuhito KOHDA, Kamaraju Kusumanchi, kohda
  • Date: 2008-04-06 15:11:41 UTC
  • mfrom: (1.1.7 upstream) (4.1.1 lenny)
  • Revision ID: james.westby@ubuntu.com-20080406151141-w0sg20jnv86mlt6f
Tags: 1:1.0.6.14-1
[Kamaraju Kusumanchi <kamaraju@gmail.com>]
* New upstream release
* 01_american.dpatch is updated
* Since thread support in guile-1.8 is now disabled, the segmentation faults
  should not arise anymore. More info at #439923. (Closes: #450499, #458685)
[kohda]
* This version fixed menu problem.  (Closes: #447083)
* Reverted orig.tar.gz to the upstream tarball.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
 
2
 
/******************************************************************************
3
 
* MODULE     : list.hpp
4
 
* DESCRIPTION: linked lists with reference counting
5
 
* COPYRIGHT  : (C) 1999  Joris van der Hoeven
6
 
*******************************************************************************
7
 
* This software falls under the GNU general public license and comes WITHOUT
8
 
* ANY WARRANTY WHATSOEVER. See the file $TEXMACS_PATH/LICENSE for more details.
9
 
* If you don't have this file, write to the Free Software Foundation, Inc.,
10
 
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
11
 
******************************************************************************/
12
 
 
13
 
#ifndef LIST_H
14
 
#define LIST_H
15
 
#include "tree.hpp"
16
 
 
17
 
class tree;
18
 
template<class T> class list_rep;
19
 
template<class T> class list;
20
 
 
21
 
template<class T> bool nil (list<T> l);
22
 
template<class T> bool atom (list<T> l);
23
 
template<class T> bool strong_equal (list<T> l1, list<T> l2);
24
 
 
25
 
template<class T> class list {
26
 
  CONCRETE_NULL_TEMPLATE(list,T);
27
 
  inline list (T item);
28
 
  inline list (T item, list<T> next);
29
 
  inline list (T item1, T item2, list<T> next);
30
 
  inline list (T item1, T item2, T item3, list<T> next);
31
 
  T& operator [] (int i);
32
 
  operator tree ();
33
 
  static list<T> init;
34
 
 
35
 
  friend bool atom LESSGTR (list<T> l);
36
 
  friend bool strong_equal LESSGTR (list<T> l1, list<T> l2);
37
 
};
38
 
 
39
 
extern int list_count;
40
 
template<class T> class list_rep: concrete_struct {
41
 
public:
42
 
  T       item;
43
 
  list<T> next;
44
 
 
45
 
  inline list_rep<T> (T item2, list<T> next2): item(item2), next(next2) {
46
 
    DEBUG(list_count++); }
47
 
  inline ~list_rep<T> () { DEBUG(list_count--); }
48
 
  friend class list<T>;
49
 
};
50
 
 
51
 
CONCRETE_NULL_TEMPLATE_CODE(list,class,T);
52
 
#define TMPL template<class T>
53
 
TMPL inline list<T>::list (T item): rep (new list_rep<T>(item, list<T> ())) {}
54
 
TMPL inline list<T>::list (T item, list<T> next):
55
 
  rep (new list_rep<T>(item, next)) {}
56
 
TMPL inline list<T>::list (T item1, T item2, list<T> next):
57
 
  rep (new list_rep<T>(item1, list<T> (item2, next))) {}
58
 
TMPL inline list<T>::list (T item1, T item2, T item3, list<T> next):
59
 
  rep (new list_rep<T>(item1, list<T> (item2, item3, next))) {}
60
 
TMPL inline bool atom (list<T> l) { return (!nil (l)) && nil (l->next); }
61
 
TMPL list<T> list<T>::init= list<T> ();
62
 
 
63
 
TMPL int      N (list<T> l);
64
 
TMPL list<T>  copy (list<T> l);
65
 
TMPL list<T>  operator * (list<T> l1, T x);
66
 
TMPL list<T>  operator * (list<T> l1, list<T> l2);
67
 
TMPL list<T>  head (list<T> l, int n=1);
68
 
TMPL list<T>  tail (list<T> l, int n=1);
69
 
TMPL T        last_item (list<T> l);
70
 
TMPL T&       access_last (list<T>& l);
71
 
TMPL list<T>& suppress_last (list<T>& l);
72
 
TMPL list<T>  reverse (list<T> l);
73
 
TMPL list<T>  remove (list<T> l, T what);
74
 
 
75
 
TMPL ostream& operator << (ostream& out, list<T> l);
76
 
TMPL list<T>& operator << (list<T>& l, T item);
77
 
TMPL list<T>& operator << (list<T>& l1, list<T> l2);
78
 
TMPL list<T>& operator >> (T item, list<T>& l);
79
 
TMPL list<T>& operator << (T& item, list<T>& l);
80
 
TMPL bool     operator == (list<T> l1, list<T> l2);
81
 
TMPL bool     operator != (list<T> l1, list<T> l2);
82
 
TMPL bool     operator < (list<T> l1, list<T> l2);
83
 
TMPL bool     operator <= (list<T> l1, list<T> l2);
84
 
#undef TMPL
85
 
 
86
 
#include "list.cpp"
87
 
 
88
 
#endif // defined LIST_H