My Project  debian-1:4.1.1-p2+ds-4
ftmpl_list.h
Go to the documentation of this file.
1 /* emacs edit mode for this file is -*- C++ -*- */
2 
3 #ifndef INCL_LIST_H
4 #define INCL_LIST_H
5 
6 #ifndef NOSTREAMIO
7 #ifdef HAVE_IOSTREAM
8 #include <iostream>
9 #define OSTREAM std::ostream
10 #elif defined(HAVE_IOSTREAM_H)
11 #include <iostream.h>
12 #define OSTREAM ostream
13 #endif
14 #endif /* NOSTREAMIO */
15 
16 template <class T>
18 
19 template <class T>
20 class List;
21 
22 #ifndef NOSTREAMIO
23 template <class T>
24 OSTREAM& operator<< ( OSTREAM &, const List<T> &);
25 #endif
26 
27 template <class T>
28 class ListItem
29 {
30 private:
33  T * item;
34 public:
35  ListItem( const ListItem<T>& );
36  ListItem( const T&, ListItem<T>*, ListItem<T>* );
38  ~ListItem();
42  T& getItem();
43 #ifndef NOSTREAMIO
44  void print ( OSTREAM& );
45 #endif /* NOSTREAMIO */
46  friend class ListIterator<T>;
47  friend class List<T>;
48 };
49 
50 template <class T>
51 class List
52 {
53 private:
56  int _length;
57 public:
58  List();
59  List( const List<T>& );
60  List( const T& );
61  ~List();
62  List<T>& operator= ( const List<T>& );
63  void insert ( const T& );
64  void insert ( const T&, int (*cmpf)( const T&, const T& ) );
65  void insert ( const T&, int (*cmpf)( const T&, const T& ), void (*insf)( T&, const T& ) );
66  void append ( const T& );
67  int isEmpty() const;
68  int length() const;
69  T getFirst() const;
70  void removeFirst();
71  T getLast() const;
72  void removeLast();
73  void sort ( int (*) ( const T&, const T& ) );
74 #ifndef NOSTREAMIO
75  void print ( OSTREAM & ) const;
76  friend OSTREAM& operator<< <T>( OSTREAM & os, const List<T> & l );
77 #endif /* NOSTREAMIO */
78  friend class ListIterator<T>;
79 };
80 
81 #ifndef NOSTREAMIO
82 template <class T>
83 OSTREAM& operator<< ( OSTREAM & os, const List<T> & l );
84 #endif /* NOSTREAMIO */
85 
86 template <class T>
87 class ListIterator {
88 private:
91 public:
92  ListIterator();
93  ListIterator( const ListIterator<T>& );
94  ListIterator( const List<T>& );
95  ~ListIterator();
98  T& getItem() const;
99  int hasItem();
100  void operator++();
101  void operator--();
102  void operator++( int );
103  void operator--( int );
104  void firstItem();
105  void lastItem();
106  void insert( const T& );
107  void append( const T& );
108  void remove( int moveright );
109 };
110 
111 template <class T>
112 int operator== (const List<T>&, const List<T>& );
113 
114 template <class T>
115 List<T> Union ( const List<T>&, const List<T>& );
116 
117 template <class T>
118 List<T> Difference ( const List<T>&, const List<T>& );
119 
120 template <class T>
121 List<T> Union ( const List<T> &, const List<T> & , int (*ecmpf)( const T&, const T& ));
122 
123 template <class T>
124 List<T> Difference ( const List<T> &, const List<T> & , int (*ecmpf)( const T&, const T& ));
125 
126 template <class T>
127 List<T> Difference ( const List<T> & F, const T & G);
128 
129 template <class T>
130 List<T> Difference ( const List<T> & F, const T & G, int (*ecmpf)( const T&, const T& ));
131 
132 template <class T>
133 List<T> Union ( const List<T>&, const List<T>&, int (*cmpf)( const T&, const T& ), void (*insf)( T&, const T& ) );
134 
135 template <class T>
136 T prod ( const List<T>& );
137 
138 template <class T>
139 bool find (const List<T>&, const T& t);
140 
141 template <class T>
142 bool find (const List<T> & F, const T& t, int (*ecmpf)( const T&, const T& ));
143 #endif /* ! INCL_LIST_H */
ListIterator::firstItem
void firstItem()
Definition: ftmpl_list.cc:478
List::_length
int _length
Definition: ftmpl_list.h:56
ListIterator::~ListIterator
~ListIterator()
Definition: ftmpl_list.cc:406
ListIterator::theList
List< T > * theList
Definition: ftmpl_list.h:89
List::List
List()
Definition: ftmpl_list.cc:86
ListIterator::operator--
void operator--()
Definition: ftmpl_list.cc:454
ListItem::print
void print(OSTREAM &)
Definition: ftmpl_list.cc:74
ListIterator::operator=
ListIterator< T > & operator=(const ListIterator< T > &)
Definition: ftmpl_list.cc:410
List::~List
~List()
Definition: ftmpl_list.cc:127
List::last
ListItem< T > * last
Definition: ftmpl_list.h:55
ListIterator::lastItem
void lastItem()
Definition: ftmpl_list.cc:485
ListIterator::append
void append(const T &)
Definition: ftmpl_list.cc:509
ListIterator::ListIterator
ListIterator()
Definition: ftmpl_list.cc:382
ListItem::getItem
T & getItem()
Definition: ftmpl_list.cc:67
ListItem::~ListItem
~ListItem()
Definition: ftmpl_list.cc:33
find
bool find(const List< T > &, const T &t)
Definition: ftmpl_list.cc:700
ListItem::ListItem
ListItem(const ListItem< T > &)
Definition: ftmpl_list.cc:6
OSTREAM
#define OSTREAM
Definition: ftmpl_list.h:9
Difference
List< T > Difference(const List< T > &, const List< T > &)
Definition: ftmpl_list.cc:622
ListIterator::insert
void insert(const T &)
Definition: ftmpl_list.cc:492
List::isEmpty
int isEmpty() const
Definition: ftmpl_list.cc:267
T
static jList * T
Definition: janet.cc:31
operator<<
OSTREAM & operator<<(OSTREAM &, const List< T > &)
Definition: ftmpl_list.cc:555
operator==
int operator==(const List< T > &, const List< T > &)
Definition: ftmpl_list.cc:176
ListIterator::operator++
void operator++()
Definition: ftmpl_list.cc:446
Union
List< T > Union(const List< T > &, const List< T > &)
Definition: ftmpl_list.cc:563
ListItem::getNext
ListItem< T > * getNext()
Definition: ftmpl_list.cc:53
ListIterator::hasItem
int hasItem()
Definition: ftmpl_list.cc:439
ListItem::prev
ListItem * prev
Definition: ftmpl_list.h:32
List::removeFirst
void removeFirst()
Definition: ftmpl_list.cc:287
ListItem
Definition: ftmpl_list.h:28
List::getFirst
T getFirst() const
Definition: ftmpl_list.cc:279
List::print
void print(OSTREAM &) const
Definition: ftmpl_list.cc:366
ListIterator::remove
void remove(int moveright)
Definition: ftmpl_list.cc:526
List::operator=
List< T > & operator=(const List< T > &)
Definition: ftmpl_list.cc:140
List::length
int length() const
Definition: ftmpl_list.cc:273
List::removeLast
void removeLast()
Definition: ftmpl_list.cc:317
ListIterator::getItem
T & getItem() const
Definition: ftmpl_list.cc:431
ListIterator::current
ListItem< T > * current
Definition: ftmpl_list.h:90
ListItem::operator=
ListItem< T > & operator=(const ListItem< T > &)
Definition: ftmpl_list.cc:40
ListItem::item
T * item
Definition: ftmpl_list.h:33
ListItem::next
ListItem * next
Definition: ftmpl_list.h:31
l
int l
Definition: cfEzgcd.cc:93
prod
T prod(const List< T > &)
Definition: ftmpl_list.cc:690
List
Definition: ftmpl_list.h:20
List::first
ListItem< T > * first
Definition: ftmpl_list.h:54
G
static TreeM * G
Definition: janet.cc:32
List::append
void append(const T &)
Definition: ftmpl_list.cc:256
List::insert
void insert(const T &)
Definition: ftmpl_list.cc:193
List::sort
void sort(int(*)(const T &, const T &))
Definition: ftmpl_list.cc:339
List::getLast
T getLast() const
Definition: ftmpl_list.cc:309
ListIterator
Definition: ftmpl_list.h:17
ListItem::getPrev
ListItem< T > * getPrev()
Definition: ftmpl_list.cc:60