]> git.donarmstrong.com Git - lilypond.git/commitdiff
flower-1.0.19
authorfred <fred>
Fri, 10 Jan 1997 09:36:18 +0000 (09:36 +0000)
committerfred <fred>
Fri, 10 Jan 1997 09:36:18 +0000 (09:36 +0000)
flower/pcursor.tcc [new file with mode: 0644]
flower/smat.cc
flower/vray.hh [deleted file]

diff --git a/flower/pcursor.tcc b/flower/pcursor.tcc
new file mode 100644 (file)
index 0000000..ffb01bc
--- /dev/null
@@ -0,0 +1,16 @@
+#include "pcursor.hh"
+
+template<class T>
+void
+PCursor<T>::junk()
+{
+#if !defined(NDEBUG) && defined(PARANOID)
+    list().OK();
+#endif
+
+    delete ptr();
+#if !defined(NDEBUG)&&defined(PARANOID)
+    thing() = 0;
+    list().OK();
+#endif
+}
index 93726ec08aab055b1c59cac0c1bd97d564c97aad..c2177d4c9916110a03b782c08de969ce38da4a71 100644 (file)
@@ -14,18 +14,22 @@ Full_storage::operator=(Full_storage const &fs)
 void
 Full_storage::OK() const
 {
+    #ifndef NDEBUG
     //    static Real dummy;           
     assert(maxh >= h && maxw >= w);
     assert(h >= 0 && w >= 0);
     assert(els||!maxh);
     if (maxh>0) {              // access outer elts.
        Real *r = els[maxh -1];
+       #if 0
        if (maxw>0) {
            assert(r);
            Real s = r[maxw -1]; // accessing unitialised memory.
            s = sin(s);
        }
+       #endif
     }
+    #endif
 }
 void
 Full_storage::resize_cols(int newh)
@@ -148,20 +152,20 @@ Full_storage::insert_row(int k)
 }
 
 
-svec<Real>
+Array<Real>
 Full_storage::row(int n) const
 {
-    svec<Real> r;
+    Array<Real> r;
     for (int j = 0; j < w; j++)
        r.add(els[n][j]);
     return r;
 }
 
-svec<Real>
+Array<Real>
 Full_storage::column(int n) const
 {
     
-    svec<Real> r;
+    Array<Real> r;
     for (int i = 0; i<h; i++)
        r.add(els[i][n]);
     return r;
diff --git a/flower/vray.hh b/flower/vray.hh
deleted file mode 100644 (file)
index 39913fc..0000000
+++ /dev/null
@@ -1,173 +0,0 @@
-/*
-  (c) Han-Wen Nienhuys 1995,96
-
-  Distributed under GNU GPL  
-*/
-
-#ifndef SVEC_H
-#define SVEC_H
-#include <assert.h>
-
-/// copy a bare (C-)array from #src# to #dest# sized  #count#
-template<class T>
-inline void arrcpy(T*dest, T*src, int count) {
-    for (int i=0; i < count ; i++)
-       *dest++ = *src++;
-}
-
-///scaleable array template, for T with def ctor.
-template<class T>
-class svec {
-protected:
-    
-    int max;
-
-    /// the data itself
-    T *thearray;
-
-    /// stretch or shrink  array.
-    void remax(int newmax) {    
-       T* newarr = new T[newmax];
-       size_ = (newmax < size_) ? newmax : size_;
-       arrcpy(newarr, thearray, size_);
-       
-       delete[] thearray;
-       thearray = newarr;
-       max = newmax;
-    }
-    int size_;
-
-public:
-    /// check invariants
-    void OK() const {
-       assert(max >= size_ && size_ >=0);
-       if (max) assert(thearray);
-    }
-    /// report the size_. See {setsize_}
-
-    int size() const  { return size_; }
-    int sz() const  { return size(); }
-    
-    /// POST: size() == 0
-    void clear() { size_ = 0; }
-
-    svec() { thearray = 0; max =0; size_ =0; }
-
-    /// set the size_ to #s#
-    void set_size(int s) {
-       if (s >= max) remax(s);
-       size_ = s;    
-    }
-    /** POST: sz() == s.
-    Warning: contents are unspecified */
-    
-    ~svec() { delete[] thearray; }
-
-    /// return a  "new"ed copy of array 
-    T* copy_array() const {
-       T* Tarray = new T[size_];
-       arrcpy(Tarray, thearray, size_);
-       return Tarray;
-    }
-    // depracated
-    operator T* () const {
-       return copy_array();    
-    }
-    void operator=(svec const & src) {
-       set_size (src.size_);
-       arrcpy(thearray,src.thearray, size_);
-    }
-    svec(const svec & src) {
-       thearray = src.copy_array();
-       max = size_ = src.size_;        
-    }
-
-    /// tighten array size_.
-    void precompute () { remax(size_); }
-
-    /// this makes svec behave like an array
-    T &operator[] (const int i) const {
-       assert(i >=0&&i<size_);
-       return ((T*)thearray)[i];       
-    }
-
-    /// add to the end of array
-    void add(T x) {
-       if (size_ == max)
-           remax(2*max + 1);
-
-       // T::operator=(T &) is called here. Safe to use with automatic
-       // vars
-       thearray[size_++] = x;
-    }
-
-    /// junk last entry.
-    void pop() { size_ -- ; }
-
-    /// return last entry
-    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) {
-       assert(j >=0 && j<= size_);
-       set_size(size_+1);
-       for (int i=size_-1; i > j; i--)
-           thearray[i] = thearray[i-1];
-       thearray[j] = k;
-    }
-    void del(int i) {
-       assert(i >=0&& i < size_);
-       arrcpy(thearray+i, thearray+i+1, size_-i-1);
-       size_--;
-    }
-    // quicksort.
-    void sort (int (*compare)(T& , T& ),
-              int lower = -1, int upper = -1 ) {
-       if (lower < 0) {
-           lower = 0 ;
-           upper = sz()-1;
-       }
-       if (lower >= upper)
-           return;
-       swap(lower, (lower+upper)/2);
-       int last = lower;
-       for (int i= lower +1; i <= upper; i++)
-           if (compare(thearray[i], thearray[lower]) < 0 )
-               swap( ++last,i);
-       swap(lower, last);
-       sort(compare, lower, last-1);
-       sort(compare, last+1, lower);
-    }
-    void concat(svec<T> const &src) {
-       int s = size_;
-       set_size(size_ + src.size_);
-       arrcpy(thearray+s,src.thearray, src.size_);     
-    }
-    svec<T> subvec(int lower, int upper) {
-       assert(lower >= 0 && lower <=upper&& upper <= size_);
-       svec<T> r;
-       int s =upper-lower;
-       r.set_size(s);
-       arrcpy(r.thearray, thearray  + lower, s);
-       return r;
-    }
-};
-/**
-
-  This template implements a scaleable vector. With (or without) range
-  checking. It may be flaky for objects with complicated con- and
-  destructors. The type T should have a default constructor. It is
-  best suited for simple types, such as int, double or String
-
-  */
-
-#endif