1 #ifndef _XFloatList_
2 #define _XFloatList_
3 
4 // by Andrew O'Meara
5 
6 #include "XPtrList.h"
7 
8 class XLongList;
9 
10 
11 class XFloatList {
12 
13 	public:
14 								XFloatList( ListOrderingT inOrdering = cOrderNotImportant );		// See XPtrList.h for ListOrderingT choices
15 
16 		// See XPtrList.h for description of functions.
Add(float inNum)17 		virtual long			Add( float inNum )								{ return mList.Add( *((void**) &inNum) );			}
Add(const XFloatList & inList)18 		virtual void			Add( const XFloatList& inList )					{ mList.Add( inList.mList );						}
RemoveElement(long inIndex)19 		virtual bool			RemoveElement( long inIndex )					{ return mList.RemoveElement( inIndex );			}
RemoveAll()20 		virtual void			RemoveAll()										{ mList.RemoveAll(); 								}
Fetch(long inIndex)21 		virtual float			Fetch( long inIndex )							{ long t = (long) mList.Fetch( inIndex ); return *((float*) &t);}
Fetch(long inIndex,float * ioPtrDest)22 		virtual bool			Fetch( long inIndex, float* ioPtrDest ) const	{ return mList.Fetch( inIndex, (void**)ioPtrDest );	}
Count()23 		virtual long			Count()	const									{ return mList.Count();								}
24 
25 		//	Post: Ranks all the values in this list.
26 		//	Post: Fetch( outRank[ i ] ) is the ith largest value in this list.
27 		//	Post: outRank.Count() == inNumToRank  (ie, only inNumToRank values of the ranking are returned)
28 		//	Note: If inNumToRank is invalid, the full ranking is returned
29 		//	Note: O( N log N ) running time
30 		void					Rank( XLongList& outRank, long inNumToRank = -1 ) const;
31 
32 		// Computes a specified number of values that represent center-values for that current list of floats
33 		// Note: if this float list isn't already sorted from LowToHigh, GetMeans() will have to perform a full sort!!
34 		void					FindMeans( long inNumMeans, float outMeans[], float inSigmaScale = 0.05 ) const;
35 
36 		// Smoothes all the floats in this list
37 		void					GaussSmooth( float inSigma );
38 
39 		float					operator[] ( const long inIndex )				{ long t = (long) mList.Fetch( inIndex ); return *((float*) &t); }
40 
41 		// Generic utility fcn to gauss-smooth a 1D curve.
42 		static void				GaussSmooth( float inSigma, long inN, float inSrceDest[] );
43 		static void				GaussSmooth( float inSigma, long inN, float inSrce[], float inDest[] );
44 
45 
46 		static void				SlopeSmooth( float inSmoothness, long inN, float ioData[] );
47 
48 	protected:
49 		static int				sFloatComparitor( const void* inA, const void* inB );
50 		static int				sQSFloatComparitor( const void* inA, const void* inB );
51 
52 		#define MASK_MAX		40
53 
54 		static float			sMask[ MASK_MAX ];
55 		static UtilStr			sTemp;
56 
57 		XPtrList				mList;
58 
59 
60 };
61 
62 
63 
64 
65 #endif
66