#include <algorithm> #include <string> #include <vector> #include <stdio.h> #include <string.h> // See http
Continue ReadingWhy doesn’t GCC optimize a*a*a*a*a*a to (a*a*a)*(a*a*a)?
I am doing some numerical optimization on a scientific application. One thing I noticed is that GCC will optimize the call pow(a,2) by compiling it in
Continue ReadingC++: Bubble Sort
#include <algorithm> template<typename Iterator> void bubbleSort(Iterator first, Iterator last) { Iterator i, j; for (i = fir
Continue ReadingC++: Merge Sort
#include <iostream> using namespace std; void merge(int a[], const int low, const int mid, const int high) { // Variables declarati
Continue ReadingRead/convert an InputStream to a String
If you have java.io.InputStream object, how should you process that object and produce a String? Suppose I have an InputStream that contains te
Continue ReadingC++ String Algorithms
[pt_view id="ce50e34ece"]
Continue ReadingC++ Sorts
[pt_view id="cd7c62717a"]
Continue ReadingCreating a Memory Leak With Java
I just had an interview, and I was asked to create a memory leak with Java. Needless to say I felt pretty dumb having no clue on how to even start cre
Continue ReadingAvoiding “!= Null” Statements in Java?
I work with Java all day long. The most used idiom (code snippet) I’m programming in Java, is to test if an object != null before I use it. This is
Continue ReadingC++: What is The Rule of Three?
What does copying an object mean? What are the copy constructor and the copy assignment operator? When do I need to declare them myself? How can I
Continue Reading




