source: git/factory/templates/ftmpl_list.h @ 6881f9b

spielwiese
Last change on this file since 6881f9b was 6881f9b, checked in by Jens Schmidt <schmidt@…>, 26 years ago
o #include <templates/config.h>, #include <templates/assetr.h> changed to #include <factoryconf> (without MAKEHEADER now) git-svn-id: file:///usr/local/Singular/svn/trunk@215 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 2.9 KB
Line 
1// emacs edit mode for this file is -*- C++ -*-
2// $Id: ftmpl_list.h,v 1.3 1997-04-30 13:08:27 schmidt Exp $
3
4#ifndef INCL_LIST_H
5#define INCL_LIST_H
6
7/*
8$Log: not supported by cvs2svn $
9Revision 1.2  1997/04/15 10:11:37  schmidt
10#include <config.h> added
11the header config.h will be included be makeheader
12
13Revision 1.1  1997/03/27 10:32:32  schmidt
14stream-io wrapped by NOSTREAMIO
15
16Revision 1.0  1996/05/17 11:06:32  stobbe
17Initial revision
18
19*/
20
21#include <factoryconf.h>
22
23#ifndef NOSTREAMIO
24#include <iostream.h>
25#endif /* NOSTREAMIO */
26
27
28template <class T>
29class ListItem
30{
31private:
32    ListItem * next;
33    ListItem * prev;
34    T * item;
35public:
36    ListItem( const ListItem<T>& );
37    ListItem( const T&, ListItem<T>*, ListItem<T>* );
38    ListItem( T* , ListItem<T>* , ListItem<T>* );
39    ~ListItem();
40    ListItem<T>& operator= ( const ListItem<T>& );
41    ListItem<T>* getNext();
42    ListItem<T>* getPrev();
43    T& getItem();
44#ifndef NOSTREAMIO
45    void print ( ostream& );
46#endif /* NOSTREAMIO */
47    friend class ListIterator<T>;
48    friend class List<T>;
49};
50
51template <class T>
52class List
53{
54private:
55    ListItem<T> *first;
56    ListItem<T> *last;
57    int _length;
58public:
59    List();
60    List( const List<T>& );
61    List( const T& );
62    ~List();
63    List<T>& operator= ( const List<T>& );
64    void insert ( const T& );
65    void insert ( const T&, int (*cmpf)( const T&, const T& ) );
66    void insert ( const T&, int (*cmpf)( const T&, const T& ), void (*insf)( T&, const T& ) );
67    void append ( const T& );
68    int isEmpty() const;
69    int length() const;
70    T getFirst() const;
71    void removeFirst();
72    T getLast() const;
73    void removeLast();
74    void sort ( int (*) ( const T&, const T& ) );
75#ifndef NOSTREAMIO
76    void print ( ostream & ) const;
77#endif /* NOSTREAMIO */
78    friend class ListIterator<T>;
79};
80
81#ifndef NOSTREAMIO
82template <class T>
83ostream& operator<<( ostream & os, const List<T> & l );
84#endif /* NOSTREAMIO */
85
86template <class T>
87class ListIterator {
88private:
89    List<T> *theList;
90    ListItem<T> *current;
91public:
92    ListIterator();
93    ListIterator( const ListIterator<T>& );
94    ListIterator( const List<T>& );
95    ~ListIterator();
96    ListIterator<T>& operator = ( const ListIterator<T>& );
97    ListIterator<T>& operator = ( const List<T>& );
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
111template <class T>
112List<T> Union ( const List<T>&, const List<T>& );
113
114template <class T>
115List<T> Difference ( const List<T>&, const List<T>& );
116
117template <class T>
118List<T> Union ( const List<T>&, const List<T>&, int (*cmpf)( const T&, const T& ), void (*insf)( T&, const T& ) );
119
120template <class T>
121T prod ( const List<T>& );
122
123#endif /* INCL_LIST_H */
Note: See TracBrowser for help on using the repository browser.