Changeset 364


Ignore:
Timestamp:
02/03/05 18:59:17 (19 years ago)
Author:
kil064
Message:

add function addEntry

Location:
trunk/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/MathUtils.cc

    r209 r364  
    7676   }
    7777}
    78 
  • trunk/src/MathUtils.h

    r176 r364  
    3737namespace mathutil {
    3838
     39// Add new entry to list
    3940template <class T>
     41casa::uInt addEntry (casa::Vector<T>& list, T val);
     42
    4043
    4144// Hanning smoothing
     45template <class T>
    4246void hanning(casa::Vector<T>& out, casa::Vector<casa::Bool>& outmask,
    4347             const casa::Vector<T>& in, const casa::Vector<casa::Bool>& mask,
  • trunk/src/MathUtils2.cc

    r209 r364  
    8989  }
    9090}
     91
     92template <class T>
     93uInt mathutil::addEntry (Vector<T>& list, T val)
     94{
     95   uInt n = list.nelements();
     96   if (n>0) {
     97      for (uInt i=0; i<n; i++) {
     98         if (near(list[i],val)) {
     99            return i;
     100         }
     101      }
     102   }
     103//
     104   n++;
     105   list.resize(n,True);
     106   list(n-1) = val;
     107   return n-1;
     108}
     109
     110
     111 
     112
     113
     114
Note: See TracChangeset for help on using the changeset viewer.