1
////////////////////////////////////////////////////////////////////////////////
3
// This file is part of Toolkit for Conceptual Modeling (TCM).
4
// (c) copyright 1995, Vrije Universiteit Amsterdam.
5
// Author: Frank Dehne (frank@cs.vu.nl).
7
// TCM is free software; you can redistribute it and/or modify
8
// it under the terms of the GNU General Public License as published by
9
// the Free Software Foundation; either version 2 of the License, or
10
// (at your option) any later version.
12
// TCM 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
15
// GNU General Public License for more details.
17
// You should have received a copy of the GNU General Public License
18
// along with TCM; if not, write to the Free Software
19
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
21
////////////////////////////////////////////////////////////////////////////////
27
#if defined(__SUNPRO_CC)
29
#if __SUNPRO_CC >= 0x500
30
template<> inline void List<string>::clear() { empty(); }
31
template<> inline void List<unsigned>::clear() { empty(); }
32
template<> inline void List<int>::clear() { empty(); }
34
inline void List<string>::clear() { empty(); }
35
inline void List<unsigned>::clear() { empty(); }
36
inline void List<int>::clear() { empty(); }
40
template <class T> List<T>::List() {
47
template <class T> List<T>::~List() {
48
Element<T> *p = head, *q;
56
template <class T> List<T>::List(const List<T> &l) {
61
unsigned s = l.count();
62
for (unsigned i = 0; i < s; i++)
67
template <class T> List<T> &List<T>::operator=(const List<T> &l) {
71
unsigned s = l.count();
72
for (unsigned i = 0; i < s; i++)
78
template <class T> List<T> *List<T>::add(const T &e) {
79
Element<T> *p = new Element<T>;
94
template <class T> void List<T>::insert(const T &e, const unsigned i) {
99
Element<T> *p = new Element<T>;
100
Element<T> *q = head;
121
template <class T> int List<T>::find(const T &e) const {
122
Element<T> *q = head;
133
template <class T> void List<T>::remove(const T &e) {
135
while ((i = find(e)) >= 0)
136
removei((unsigned) i);
139
template <class T> void List<T>::removei(const unsigned i) {
141
Element<T> *q = head;
147
q->prev->next = q->next;
151
q->next->prev = q->prev;
160
// added by David N. Jansen <dnjansen@cs.utwente.nl>
161
template <class T> bool List<T>::removecur() {
164
Element<T> *q = current;
167
q->prev->next = current;
171
current->prev = q->prev;
179
// added by Rik Eshuis <eshuis@cs.utwente.nl>
180
template <class T> bool List<T>::isSet(void) const {
181
Element<T> *q = head;
183
if (count(q->item)>1)
190
// added by Rik Eshuis <eshuis@cs.utwente.nl>
191
template <class T> int List<T>::count(const T &e) const {
193
Element<T> *q = head;
203
// added by Rik Eshuis <eshuis@cs.utwente.nl>
204
// The following procedure is a bit inefficient since multiple
205
// elements are counted every time they occur in list l
206
//template <class T> bool List<T>::contains(List<T> *l) const {
207
// for (l->first();!l->done();l->next()){
208
// if (l->count(l->cur()) > this->count(l->cur()))
214
template <class T> T &List<T>::operator[] (const unsigned i) const {
215
Element<T> *q = head;
222
template <class T> T &List<T>::elem(const unsigned i) const {
223
Element<T> *q = head;
230
template <class T> void List<T>::replace(const T &old, const T &fresh) {
231
Element<T> *q = head;
237
template <class T> void List<T>::sort(int (*cmp)(T, T)) {
241
for (p=head; p->next!=0; p=p->next) {
242
for(q=tail;(p!=q && p!=q->next); q=q->prev) {
243
if ((*cmp) (q->item, q->prev->item) < 0) {
245
q->item = q->prev->item;
246
q->prev->item = temp;
252
template <class T> void List<T>::reverse() {
256
for (p=head,q=tail; (p!=q && p!=q->next);p=p->next,q=q->prev) {
263
template <class T> void List<T>::empty() {
264
Element<T> *p = head, *q;
276
template <class T> void List<T>::clear() {
277
Element<T> *p = head, *q;
280
// dangerous when p is not a pointer.
298
template <class T> int List<T>::setcur(const T &e) {
299
Element<T> *q = head;
311
// template <class T> ostream &operator<<(ostream &o, const List<T> &l) {
312
// Element<T> *q = l.head;
319
#include "instances.h"
323
#include "xlcinstances.h"