Ben Chuanlong Du's Blog

And let it direct your passion with reason.

Lvalue Reference and Rvalue Reference

Difference betwen Lvalue and Rvalue Reference

  1. Lvalue and Rvalue are terrible names. They are due to historical reasonal but people stuck with these names.

  2. A lvalue reference has a name while a rvalue reference has no name, in other words, a lvalue reference is persistent while a rvalue reference is …

Interact with System Clipboard in Vim

The following are ways for a Vim session to interact (copy/cut, paste) with other Vim sessions or other applications.

Use X Windows Clipboard Directly

If you prefer to use X windows clipboard as the default buffer for Vim, put set clipboard=unnamedplus in your .vimrc file. This obviously makes …

Stick Breaking Problems

The following is a popular brain teaser problem about probability.

Randomly select two points on a unit stick to break it into 3 pieces, what is the probability that the 3 pieces can form a triangle?

The critical thing here is how are the two points selected. The most popular …

Copy Arrays in Java

There are several different ways to copy arrays of object (primitive types) in Java. However, the fastest way seems to be System.arraycopy. This methed is implemented using native code and only performs a shallow copy. Acutally most methods for copying arrays in Java perform shallow copy.

int arr1[] = {0 …

Type Cast in Java

  1. You cannot cast between integer and boolean values. However it is trivia to convert data between integer and boolean. For example, int i = b ? 1 : 0; convert a boolean value b into an integer value i, and boolean b = i != 0 convert an integer value i into a boolean value …

String in Different Programming Languages

A string is essentially a sequence of characters. This is how string is implemented in many programming languages (string in Java is different). For this reason, you can operate string like an array in some programming languages. This post is a shallow summary on strings in different programming languages. For …