Finding substrings within strings using the Boyer-Moore-Horspool Algorithm in C++

TweetEver wondered what computer algorithm gets employed when using Ctrl-F to search for specific words in a page of text? A number of potential string searching techniques exist. One possible candidate implementation is Nigel Horspool’s Boyer-Moore-Horspol algorithm – an exceptionally … Continue reading


Number System Conversions in C++

TweetA posting which I will probably update from time to time that summarizes the conversion functions I encounter in C++. Hope others will find this useful too. 32-bit IEEE 754 floating point value to binary string std::string GetBinary32( float value … Continue reading


Converting between binary and decimal representations of IEEE 754 floating-point numbers in C++, Java and Python

TweetThis post implements a previous post that explains how to convert 32-bit floating point numbers to binary numbers in the IEEE 754 format. What we have is some C++ / Java / Python routines that will allows us to convert … Continue reading


Mapping Words to Line Numbers in Text Files in STL / C++

TweetFollowing on from the previous post, this example shows an example of how to use an STL multimap to track the line number(s) associated with each word in a text file. This program essentially reads in text line-by-line, while stripping … Continue reading


Counting the Number of Words in a Text File in STL / C++

TweetThis post aims to illustrate the power of using STL’s associative arrays as a word counter. It reads the entire contents of the text file, word-by-word, and keeps a running total of the number of occurences of each word. All … Continue reading


Java Strings: The Basics

TweetOne long section of code outlining how to achieve some basic string handling objectives in Java. Currently trying to get to grips with this language after spending far too many years concentrating on C++. Each technique is demonstrated with a … Continue reading


Some neat examples of C++ String Formatting

TweetSome neat string formatting A pretty neat snippet found on stackoverflow recently (kudos David Rodriguez), that is worth repeating. I’m gonna start using this. Essentially it is a bit of in-house stream formatting. This class make_string produces an instance of … Continue reading