install windows 7 from usb drive

http://kmwoley.com/blog/?p=345

Step 1: Format the Drive
The steps here are to use the command line to format the disk properly using the diskpart utility. [Be warned: this will erase everything on your drive. Be careful.]

vi命令

(转载)
进入vi的命令
Vi   filename    打开或新建文件,并将光标置于第一行首
Vi   +n   filename 打开文件,并将光标置于第n行首
Vi   +    filename  打开文件并将光标置于最后一行首
Vi   +/pattern filename 打开文件,并将光标置于一个与pattern匹配的串处
Vi   filename .. Filename  打开多个文件,依次进行编辑

What is the "Named Constructor Idiom"?

A technique that provides more intuitive and/or safer construction operations for users of your class.

The problem is that constructors always have the same name as the class. Therefore the only way to differentiate between the various constructors of a class is by the parameter list. But if there are lots of constructors, the differences between them become somewhat subtle and error prone.

With the Named Constructor Idiom, you declare all the class's constructors in the private or protected sections, and you provide public static methods that return an object. These static methods are the so-called "Named Constructors." In general there is one such static method for each different way to construct an object.

Problems with inline functions in C++

(From http://)

Besides the problems associated with inline expansion in general, inline functions as a language feature may not be as valuable as they appear, for a number of reasons:

    * Often, a compiler is in a better position than a human to decide whether a particular function should be inlined. Sometimes the compiler may not be able to inline as many functions as the programmer indicates.
    * An important point to note is that the code (of the inline function) gets exposed to its client(the calling function).

Bubble Sort

The Bubble sort has a worst-case running time of Θ(n^2).

//compare the consecutive numbers, larger one sinks to the bottom
void bubbleSort(int *a)
{
// int temp;
  for(int j = 0; j < arraysize; j++) 
  { 
    for( int i = 0; i < arraysize - j - 1;i++ )
    { 
       if( a[i] > a[i+1] ) 
      {swap(a[i], a[i+1]);} 
      }
  }
}

Heapsort

“Like merge sort, but unlike insertion sort, heapsort’s running time is O(n*lg(n)). Like insertion sort, but unlike merge sort, heapsort sorts in place: only a constant number of array elements are stored outside the input array at any time. Thus, heapsort combines the better attribute of the two sorting algorithms …” [Introduction to Algorithms]

void heapSort(int *a)
{
    for(int i = arraySize; i > 1; --i)
    {
        for(int k = 0; k < i; ++k)
        {
            // compare each element with its parent
            // if the child is begger than its parent
            // then swap them
            // keep doing this until reaching the root
            while((a[k] > a[k/2]) && (k > 0))
            { 
                swap(a[k], a[k/2]); 
                k = k/2; 
            }
        }
        // After the for loop, the largest is put at a[0]
        // then put the largest to the end of the array
        // and find the largest of the rest in the same way
        swap(a[0], a[i-1]);
    }
}

Merge Sort

The merge sort has a worst case running time of Θnlg(n).

Insertion Sort

Insertion sort has a worst-case running time of Θ(n^2).
void insertionSort(int *a, int n)
{
    for (int j = 1; j < n; ++j)
    {
        int key = a[j];

        // Insert A[j] into the sorted sequence A[0, 1,...,j-1]
        int i = j-1;
        while ((i >= 0) && (key < a[i]))
        {
            a[i+1] = a[i];
            --i;
        }
        a[i+1] = key;
    }
}

Memory Allocation in C++

C++ provides two ways to allocate and free unconstructed, raw memory:

1. The allocator class, which provides type-aware memory allocation. This class supports an abstract interface to allocating memory and subsequently using that memory to hold objects.
2. The library operator new and operator delete functions, which allocated and free raw, untyped memory of a requested size.

C++ also provides various ways to construct and destroy objects in raw memory:

C++: this指针的含义及用法

(From http)
1. this指针是一个隐含于每一个成员函数中的特殊指针。它指向正在被该成员函数操作的那个对象。
2. 当对一个对象调用成员函数时,编译程序先将对象的地址赋给this指针,然后调用成员函数,每次成员函数存取数据成员时,由隐含使用this指针。
3. 当一个成员函数被调用时,自动向它传递一个隐含的参数,该参数是一个指向这个成员函数所在的对象的指针。
4. 在C++中,this指针被隐含地声明为: X *const this,这意味着不能给this 指针赋值