10 TOP Algorithms

A* search algorithm

Graph search algorithm that finds a path from a given initial node to a given goal node. It employs a heuristic estimate that ranks each node by an estimate of the best route that goes through that node. It visits the nodes in order of this heuristic estimate. The A* algorithm is therefore an example of best-first search. Continue reading

Static Initialization Function in Classes

Content

Sometime when we write a C++ class, we want a static function is used to initialize the class. For example, a static function is used to initialize a static vector or map. We can do the same thing easily in Java, by Java’s static block. How we can do with C++?

At first, let’s see how to initialize a normal static member in C++.

class Test1
{
    public:static string emptyString;
};
string Test1::emptyString = "";
// also can be
// string Test1::emptyString;
// string Test1::emptyString("");

Continue reading