I'm using the HDF5 File System for holding time series information. Rather than writing my own binary search implementation to find particular elements within a particular saved time series, I thought it would be clever if I designed the interface so I could use the Standard Template Library's 'find' iterator. If I can make the STL's 'find' work, then all the other iterators should work just as well, and thus I'll have an easy mechanism to access time series with very little programming involved. Continue reading "C++ Custom Containers and Iterators" »
Wednesday, March 26. 2008
C++ Custom Containers and Iterators
Sunday, March 23. 2008
C++ Implementation of Wu Manber's Multi-Pattern Search Algorithm
I'm finding that this algorithm is useful in a number of situations. Out in the real world, it is found in Network Intrusion Scanners, grep engines, as well as text processing. Continue reading "C++ Implementation of Wu Manber's Multi-Pattern..." »
Monday, March 17. 2008
Don't Use Defined Macros, Use Templated Inline Functions Instead
In the olden C days, one would use #define MACRO .... to build an inline macro for computationally quick evaluation of some calculation. When using that method of programming, one needed to remember to parenthesize extensively in order to prevent wierd things from happening when calling the function with an expression.
The modern approach is to use a template for an inline function, which yields all the efficiency of a macro, plus all the predictable behavior and type safety of a regular function (item #2 in the book Effective C++). An example declaration follows:
template<typename T> inline void DoWithMax( const T& a, const T& b ) { f( a > b ? a : b ); }