diff options
author | Han-Wen Nienhuys <hanwen@xs4all.nl> | 1996-11-01 17:48:30 +0100 |
---|---|---|
committer | Han-Wen Nienhuys <hanwen@xs4all.nl> | 1996-11-01 17:48:30 +0100 |
commit | 74e0f769a23454f038d20270463c734a9c22f5f9 (patch) | |
tree | 5c6dfd530af24e22b8154bf1c6bc7a787d5f3b25 /flower | |
parent | 3daac955f29e408aa2aa271a883195ddc54633f4 (diff) |
release: 0.0.4
Diffstat (limited to 'flower')
-rw-r--r-- | flower/Makefile | 2 | ||||
-rw-r--r-- | flower/Sources.make | 10 | ||||
-rw-r--r-- | flower/TODO | 2 | ||||
-rw-r--r-- | flower/cursor.hh | 16 | ||||
-rw-r--r-- | flower/cursor.inl | 5 | ||||
-rw-r--r-- | flower/dataf.cc | 12 | ||||
-rw-r--r-- | flower/list.cc | 31 | ||||
-rw-r--r-- | flower/list.hh | 34 | ||||
-rw-r--r-- | flower/list.inl | 44 | ||||
-rw-r--r-- | flower/matdebug.cc | 3 | ||||
-rw-r--r-- | flower/pcursor.hh | 14 | ||||
-rw-r--r-- | flower/plist.cc | 16 | ||||
-rw-r--r-- | flower/stringutil.hh | 4 |
13 files changed, 84 insertions, 109 deletions
diff --git a/flower/Makefile b/flower/Makefile index aff8ac8f14..4533783563 100644 --- a/flower/Makefile +++ b/flower/Makefile @@ -1,6 +1,6 @@ MAJVER=1 MINVER=0 -PATCHLEVEL=3 +PATCHLEVEL=4 PACKAGENAME=flower VERSION=$(MAJVER).$(MINVER).$(PATCHLEVEL) diff --git a/flower/Sources.make b/flower/Sources.make index 6521100b3b..fd5dcf4146 100644 --- a/flower/Sources.make +++ b/flower/Sources.make @@ -1,12 +1,12 @@ cc=lgetopt.cc string.cc dataf.cc textdb.cc unionfind.cc \ smat.cc matrix.cc choleski.cc vector.cc dstream.cc\ - matdebug.cc + matdebug.cc -templatecc=cursor.cc list.cc tsmat.cc -inl=findcurs.inl link.inl list.inl -hh=cursor.hh pcursor.hh cursor.inl lgetopt.hh link.hh list.hh dstream.hh \ +templatecc=cursor.cc list.cc tsmat.cc plist.cc +inl=findcurs.inl link.inl list.inl plist.inl cursor.inl +hh=cursor.hh pcursor.hh lgetopt.hh link.hh list.hh dstream.hh \ string.hh stringutil.hh vray.hh textdb.hh textstr.hh assoc.hh\ findcurs.hh unionfind.hh compare.hh handle.hh matrix.hh\ smat.hh vsmat.hh vector.hh real.hh choleski.hh\ - tsmat.hh tvsmat.hh + tsmat.hh tvsmat.hh plist.hh\ diff --git a/flower/TODO b/flower/TODO index 8d6e50591d..6f0f451cce 100644 --- a/flower/TODO +++ b/flower/TODO @@ -1,4 +1,6 @@ + * efficient copy cons for List + * change String::pos s[s.pos('%')] == '%' diff --git a/flower/cursor.hh b/flower/cursor.hh index cff93c68ce..1c61b1a76c 100644 --- a/flower/cursor.hh +++ b/flower/cursor.hh @@ -11,7 +11,10 @@ template<class T> class Cursor { public: - Cursor( List<T>& list, Link<T>* pointer = 0 ); + Cursor( const List<T>& list, Link<T>* pointer = 0 ); + /** this isn't true, actually, #list# surely isn't const, but I get + tired of the warning messages. */ + Cursor( const Cursor<T>& cursor ); /// return current T @@ -100,17 +103,8 @@ private: /* - comparations. + comparisons. */ - - - - - - - - - #include "compare.hh" template<class T> diff --git a/flower/cursor.inl b/flower/cursor.inl index a4e03492b5..bdc242590f 100644 --- a/flower/cursor.inl +++ b/flower/cursor.inl @@ -6,12 +6,11 @@ template<class T> inline -Cursor<T>::Cursor( List<T>& list, Link<T>* pointer ) : - list_( list ) +Cursor<T>::Cursor( const List<T>& list, Link<T>* pointer ) : + list_((List<T>&) list ) { if ( list.size() ) pointer_ = pointer ? pointer : list.top_; - //list.top().pointer_; // ARGH! recursion. else pointer_ = pointer; } diff --git a/flower/dataf.cc b/flower/dataf.cc index e53c716d8b..d050e278c5 100644 --- a/flower/dataf.cc +++ b/flower/dataf.cc @@ -110,16 +110,14 @@ String Data_file::get_line() void Data_file::gobble_leading_white() { - char c; - // eat blank lines. - while (!eof()) - { - c = data_get(); - if (!isspace(c)) + while (!eof()) { + char c = data_get(); + if (!isspace(c)) { + data_unget(c); break; } - data_unget(c); + } } diff --git a/flower/list.cc b/flower/list.cc index 782b3da86e..741e4ee97c 100644 --- a/flower/list.cc +++ b/flower/list.cc @@ -4,6 +4,15 @@ #include "list.hh" template<class T> +List<T>::List(List const&src) +{ + set_empty(); + // probably el stupido + for (Cursor<T> c(src); c.ok(); c++) + bottom().add(c); +} + +template<class T> void List<T>::OK() const { @@ -29,7 +38,7 @@ template<class T> Cursor<T> List<T>::top() { - +#if 0 // ?? waarvoor is deze if ? if ( top_ ) // equivalent: if ( size_ ) { @@ -42,7 +51,9 @@ List<T>::top() t = top_->previous(); } } - // list empty: Cursor not ok() +#endif + +// list empty: Cursor not ok() return Cursor<T>( *this, top_ ); } @@ -70,20 +81,4 @@ List<T>::bottom() } -// not inlined since it assumes knowledge of destructor. -template<class T> -inline void -PointerList<T>::remove( Cursor<T> me ) -{ - if ( me.ok() ) - { - - delete *me; - List<T>::remove( me ); - } -} - - - - #endif diff --git a/flower/list.hh b/flower/list.hh index a45252b8c3..6edf4aebc4 100644 --- a/flower/list.hh +++ b/flower/list.hh @@ -11,10 +11,12 @@ template<class T> class Link; template<class T> class List { - public: - /// construct empty list - List(); + List(List const&src); + public: + /// construct empty list + List(); + /// construct list from first item. List( const T& thing ); @@ -28,6 +30,11 @@ class List protected: friend class Cursor<T>; friend class Link<T>; + /// make *this empty + void set_empty(); + /** + WARNING: contents lost, and not deleted. + */ /// add after after_me void add( const T& thing, Cursor<T> after_me ); @@ -67,32 +74,13 @@ class List */ -/// Use for list of pointers, e.g. PointerList<AbstractType*>. -template<class T> -class PointerList : public List<T> -{ - public: - PointerList(); - PointerList( const T& thing ); - - /// - virtual ~PointerList(); - /** - This function deletes deletes the allocated pointers of all links. - #\Ref{~List}# is used to delete the links themselves. - */ - - protected: - virtual void remove( Cursor<T> me ); -}; - #include "list.inl" #include "cursor.hh" // instantiate a template: explicit instantiation. #define L_instantiate(a) template class List<a>; template class Cursor<a>; \ template class Link<a> -#define PL_instantiate(a) L_instantiate(a *); template class PointerList<a*> + #endif // __LIST_HH // diff --git a/flower/list.inl b/flower/list.inl index 8396156b6a..8bdcf15877 100644 --- a/flower/list.inl +++ b/flower/list.inl @@ -5,6 +5,13 @@ template<class T> inline List<T>::List() { + set_empty(); +} + +template<class T> +inline void +List<T>::set_empty() +{ top_ = bottom_ = 0; size_ = 0; } @@ -13,8 +20,7 @@ template<class T> inline List<T>::List( const T& thing ) { - top_ = bottom_ = 0; - size_ = 0; + set_empty(); add( thing, Cursor<T>( *this, bottom_ ) ); } @@ -113,40 +119,6 @@ List<T>::size() const return size_; } -template<class T> -inline -PointerList<T>::PointerList() : - List<T>() -{ -} - -template<class T> -inline -PointerList<T>::PointerList( const T& thing ) : - List<T>( thing ) -{ -} - -template<class T> -inline -PointerList<T>::~PointerList() -{ - Cursor<T> next(*this); - for ( Cursor<T> c( *this ); c.ok(); c = next ) { - next = c; - next++; - remove( c ); // PointerList::remove deletes the real data - } -} - -template<class T> -inline void -PointerList_print( PointerList<T> const & l ) -{ - List<T>& promises_to_be_const = (List<T>&) l; - for ( Cursor<T> c( promises_to_be_const ); c.ok(); c++ ) - (*c)->print(); -} #endif diff --git a/flower/matdebug.cc b/flower/matdebug.cc index 5a31312386..1c3df9dda1 100644 --- a/flower/matdebug.cc +++ b/flower/matdebug.cc @@ -34,10 +34,9 @@ Matrix::print() const Vector::operator String() const { - int i=0; String s("vector ["); #ifndef NDEBUG - for (; i < dim(); i++) { + for (int i=0; i < dim(); i++) { s += String(dat[i], "%6f") + ' '; } #endif diff --git a/flower/pcursor.hh b/flower/pcursor.hh index 8b0b179b4f..eb0e8f15f9 100644 --- a/flower/pcursor.hh +++ b/flower/pcursor.hh @@ -1,4 +1,13 @@ +/* + pcursor.hh -- part of flowerlib + + (c) 1996 Han-Wen Nienhuys&Jan Nieuwenhuizen +*/ + +#ifndef PCURSOR_HH +#define PCURSOR_HH + /// cursor which feels like a pointer template<class T> @@ -13,14 +22,15 @@ struct PCursor : public Cursor<T> { PCursor<T> operator +( int no) const { return PCursor<T> (Cursor<T>::operator+(no)); } - PCursor(List<T> & l) : Cursor<T> (l) {} + PCursor(const List<T> & l) : Cursor<T> (l) {} PCursor( const Cursor<T>& cursor ) : Cursor<T>(cursor) { } T operator ->() { return *(*this); } }; /** - HWN: I'd like an operator->(), so here it is. + I like operator->(), so here it is. Cursor to go with pointer list. */ +#endif diff --git a/flower/plist.cc b/flower/plist.cc new file mode 100644 index 0000000000..bbb0e7428f --- /dev/null +++ b/flower/plist.cc @@ -0,0 +1,16 @@ +#include "plist.hh" + +// not inlined since it assumes knowledge of destructor. +template<class T> +void +PointerList<T>::remove( Cursor<T> me ) +{ + if ( me.ok() ) { + delete *me; + List<T>::remove( me ); + } +} + + + + diff --git a/flower/stringutil.hh b/flower/stringutil.hh index fe0b8e307b..d7f7081617 100644 --- a/flower/stringutil.hh +++ b/flower/stringutil.hh @@ -6,11 +6,12 @@ #define NDEBUG BLONDE #endif +const INITIALMAX=8; class String_handle; /// Internal String struct class StringData { // GNU malloc: storage overhead is 8 bytes anyway. - const int INITIALMAX =8; // how to do this in ANSI C++ ? + friend class String_handle; int maxlen; // maxlen is arraysize-1 @@ -156,6 +157,7 @@ friend class String_handle; the data itself. Handles simple tasks (resizing, resetting) */ + /****************************************************************/ /// ref. counting for strings class String_handle { |