Recent Posts

Using heap is C++

2 minute read

Heap is a very important and widely used in any programing language. Unlike queue and stack, there are no dedicated class for heap in C++. However, there are some functions that let you work with heap in C++. This post will discuss about these functions and how should we use them. 1. make_heap() template <class RandomAccessIterator, class Compare> void make_heap (RandomAccessIterator first, RandomAccessIterator last, Compare comp ); A heap in C++ is a max-heap by default, the default comparator is operator<, if you want a min_heap change the comp arguments to something like std::greater<int>().the eleme...

Notes on C++ class constructor and destructor

5 minute read

In this posts, I will list some notes that I think they worth to be reminded when mentioning about classes’ declaration, constructor, and destructor. 1. In-class member function is inline function If you define a method member inside the class declaration such as class People { string first_name() {return _fname;} string last_name(); } string People::last_name {return _lname;} Then first_name() function will be an inline function by default while the function last_name() is not. Remember the good and the bad of an inline function. On the good side, an inline function can remove the overhead of the function calling mechanism, thus, i...

Jekyll custom plugins in Github page

2 minute read

Github page, which uses Jekyll as it static site generator, is a very convenient way to host a personal website. However, Github only supports some official plugins they listed, to use other plugins, you have to build the site yourself. In this post, I would like to discuss their difficulties and how to overcome them. Problems The first problem is, of course, Github does not support custom plugins and they have a valid point to do so - security. Allowing arbitrary code to run on their server is somewhat vulnerable and they don’t want to do so. Hence, I do not expect them to change that anytime soon. However, some plugins are really helpful...