diff options
author | Han-Wen Nienhuys <hanwen@xs4all.nl> | 1996-12-19 11:51:15 +0100 |
---|---|---|
committer | Han-Wen Nienhuys <hanwen@xs4all.nl> | 1996-12-19 11:51:15 +0100 |
commit | b346828b743d4fe2636a6e58597b3cb6d547357d (patch) | |
tree | 60a5decadb057ab3c5f74c37a0dfa54090eeac9f /flower | |
parent | 64d55ba1ace6eb1a4e8e1798a0e377bff19ae5cc (diff) |
release: 0.0.15
Diffstat (limited to 'flower')
-rw-r--r-- | flower/Variables.make | 4 | ||||
-rw-r--r-- | flower/compare.hh | 3 | ||||
-rw-r--r-- | flower/cursor.hh | 9 | ||||
-rw-r--r-- | flower/interval.cc | 28 | ||||
-rw-r--r-- | flower/interval.hh | 14 | ||||
-rw-r--r-- | flower/pcursor.hh | 44 | ||||
-rw-r--r-- | flower/real.hh | 6 | ||||
-rw-r--r-- | flower/vray.hh | 5 |
8 files changed, 74 insertions, 39 deletions
diff --git a/flower/Variables.make b/flower/Variables.make index e0f94d6555..83a740ac4a 100644 --- a/flower/Variables.make +++ b/flower/Variables.make @@ -1,13 +1,13 @@ MAJVER=1 MINVER=0 -PATCHLEVEL=14 +PATCHLEVEL=15 PACKAGENAME=flower VERSION=$(MAJVER).$(MINVER).$(PATCHLEVEL) DNAME=$(PACKAGENAME)-$(VERSION) DEFINES=-DNDEBUG -O2 #DEFINES=-g -CXXFLAGS+=$(DEFINES) -Wall -W -pedantic +CXXFLAGS+=$(DEFINES) -Wall -W CXXVER=$(CXX) --version include Sources.make diff --git a/flower/compare.hh b/flower/compare.hh index df278a2bfb..40bc9d2951 100644 --- a/flower/compare.hh +++ b/flower/compare.hh @@ -19,7 +19,8 @@ operator op(type t1, type t2)\ return (t1 opp t2) ? t1 : t2;\ }\ -#ifdef __GNUC__ + +#if defined (__GNUG__) && ! defined (__STRICT_ANSI__) #define gpp_minmax(type, prefix)\ prefix gpp_minmax_operator(type, <?, <)\ prefix gpp_minmax_operator(type, >?, >) diff --git a/flower/cursor.hh b/flower/cursor.hh index 6d40bb270d..428a52748f 100644 --- a/flower/cursor.hh +++ b/flower/cursor.hh @@ -84,7 +84,7 @@ class Cursor /// access the list this came from List<T>& list() const ; Link<T>* pointer(); - + static int compare(Cursor<T> a,Cursor<T>b) { return a-b; } private: List<T>& list_; Link<T>* pointer_; @@ -104,13 +104,8 @@ private: */ #include "compare.hh" -template<class T> -inline int cursor_compare(Cursor<T> a,Cursor<T>b) -{ - return a-b; -} -template_instantiate_compare(Cursor<T>, cursor_compare, template<class T>); +template_instantiate_compare(Cursor<T>, Cursor<T>::compare, template<class T>); #include "pcursor.hh" #include "list.hh" diff --git a/flower/interval.cc b/flower/interval.cc index 6cc2a7916e..6fac1f55dc 100644 --- a/flower/interval.cc +++ b/flower/interval.cc @@ -31,6 +31,29 @@ Interval::intersect(Interval h) min = MAX(h.min, min); max = MIN(h.max, max); } +Interval +intersection(Interval a, Interval const&b) +{ + a.intersect(b); + return a; + +} +int +Interval::compare(const Interval&a,Interval const&b) +{ + if (a.min == b.min && a.max == b.max) + return 0; + + if (a.min <= b.min && a.max >= b.max) + return 1; + + if (a.min >= b.min && a.max <= b.max) + return -1; + + assert(false); // not comparable + + return 0; +} Interval intersect(Interval x, Interval const &y) @@ -48,3 +71,8 @@ Interval::operator String() const return s + min + "," + max +"]"; } +bool +Interval::elt_q(Real r) +{ + return r >= min && r <= max; +} diff --git a/flower/interval.hh b/flower/interval.hh index 6f9fa63f67..a7a269153b 100644 --- a/flower/interval.hh +++ b/flower/interval.hh @@ -48,13 +48,23 @@ struct Interval { max +=r; return *this; } - + bool elt_q(Real r); operator String() const; -}; + /// partial ordering + static compare(const Interval&,Interval const&); +}; +/** + this represents the closed interval [min,max] + */ Interval intersection(Interval, Interval const&); +#include "compare.hh" + +instantiate_compare(Interval&, Interval::compare); + #endif // INTERVAL_HH + diff --git a/flower/pcursor.hh b/flower/pcursor.hh index c9cc53411f..eeaa866ea8 100644 --- a/flower/pcursor.hh +++ b/flower/pcursor.hh @@ -11,21 +11,21 @@ /// cursor to go with PointerList template<class T> -struct PCursor : public Cursor<void *> { - - /// make cursor with #no# items back - PCursor<T> operator -( int no) const { - return PCursor<T> (Cursor<void*>::operator-(no)); - } - int operator -(PCursor<T> op) const { - return Cursor<void*>::operator-(op); - } - /// make cursor with #no# items further - PCursor<T> operator +( int no) const { - return PCursor<T> (Cursor<void*>::operator+(no)); - } +struct PCursor : private Cursor<void *> { + friend class IPointerList<T>; +public: + Cursor<void*>::ok; + Cursor<void*>::del; + Cursor<void*>::backspace; - PCursor(const PointerList<T> & l) : Cursor<void*> (l) {} + PointerList<T> &list() { return (PointerList<T>&)Cursor<void*>::list(); } + PCursor<T> operator++(int) { return Cursor<void*>::operator++(0);} + PCursor<T> operator--(int) { return Cursor<void*>::operator--(0); } + PCursor<T> operator+=(int i) { return Cursor<void*>::operator+=(i);} + PCursor<T> operator-=(int i) { return Cursor<void*>::operator-=(i); } + PCursor<T> operator -(int no) const { return Cursor<void*>::operator-(no);} + int operator -(PCursor<T> op) const { return Cursor<void*>::operator-(op);} + PCursor<T> operator +( int no) const {return Cursor<void*>::operator+(no);} PCursor(const PointerList<T> & l) : Cursor<void*> (l) {} PCursor( const Cursor<void*>& cursor ) : Cursor<void*>(cursor) { } void* vptr() const { return * ((Cursor<void*> &) *this); } @@ -36,11 +36,10 @@ struct PCursor : public Cursor<void *> { operator T() { return ptr(); } T operator *() { return ptr(); } void add(const T& p ) { Cursor<void*>::add((void*) p); } - void insert(const T& p ) { Cursor<void*>::insert((void*) p);} - -private: -// Cursor<void*>::operator void*; - // sigh + void insert(const T& p ) { Cursor<void*>::insert((void*) p);} + static int compare(PCursor<T> a,PCursor<T>b) { + return Cursor<void*>::compare(a,b); + } }; /** don't create PointerList<void*>'s. @@ -49,13 +48,8 @@ private: */ -template<class T> -inline int pcursor_compare(PCursor<T> a,PCursor<T>b) -{ - return cursor_compare(Cursor<void*>(a),Cursor<void*> (b)); -} #include "compare.hh" -template_instantiate_compare(PCursor<T>, pcursor_compare, template<class T>); +template_instantiate_compare(PCursor<T>, PCursor<T>::compare, template<class T>); #endif diff --git a/flower/real.hh b/flower/real.hh index 1f2187c8c1..68e90f9b71 100644 --- a/flower/real.hh +++ b/flower/real.hh @@ -21,5 +21,9 @@ int sgn(Real x) { if (!x)return 0; return (x > 0) ?1: -1; } - +inline Real +distance(Real x,Real y) +{ + return ABS(x-y); +} #endif diff --git a/flower/vray.hh b/flower/vray.hh index 302499b256..180008c4c6 100644 --- a/flower/vray.hh +++ b/flower/vray.hh @@ -105,13 +105,16 @@ public: T& last(int j=0) { return (*this)[size-j-1]; } + T last(int j=0) const { + return (*this)[size-j-1]; + } void swap (int i,int j) { T t((*this)[i]); (*this)[i]=(*this)[j]; (*this)[j]=t; } bool empty() { return !size; } - void insert(T&k, int j) { + void insert(T k, int j) { assert(j >=0 && j<= size); set_size(size+1); for (int i=size-1; i > j; i--) |