Archive for 三月, 2013

Customized version of Stack C++(自定义版本)

Stack1.h   #ifndef stack_ #define stack_ #include "stdafx.h" //#include <iostream> //using namespace std; //exception class OutOfBounds{ public: OutOfBounds(){} }; //change array's size template<class T> void Changesize1D(T * &arr,const int& size,const int& ToSize){ T* tmp = new T[size]; tmp = arr; arr = new T[ToSize]; for(int i=0; i< size; ++i){ arr[ […]

C++ Stack Application – (Parenthesis Matching) 堆栈应用之”括号匹配”

In this problem we are to match the left and right parentheses in a character string. For example, the string (a*(b+c)+d) has left parentheses at positions 0 and 3 and right parentheses at positions 7 and 10. The left parenthesis at position 0 matches the right at position 10, while the left parenthesis at position 3 matches the right parenthesis at position 7. In the string (a+b))(, the right par […]

Comparison of Layout_gravity and gravity. And sometimes Layout_gravity does not work

  <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical"> <!– The layout_gravity example –> <LinearLayout android:layout_width="fill_parent" an […]

HeapSort(堆排序 C++)

Heaps   Heap Definition   A max tree(min tree) is a tree in which the value in each node is greater(less) than or equal to those in its children(if any)     Building a max heap   Look at below figure, we adjust elements in a array,  swap some elements, at last we have a max heap. The  progress begin from the last smallest heap. If it is a illegal max heap, we swap elements […]

Face Normals & Vertex Normals(面法线跟顶点法线的区别)

What is a face normal?   A face normal is a vector that describes the direction a polygon is facing(see figure 1) Figure 1: The face normal of a surface     What is a vertex normal?   Vertex normal have some relationships with face normal. We will discuss it in “How to calculate face normal and vertex normal?” Sometimes we can set vertex normal just as same as face […]