This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
struct SBinaryTreeNode // a node of the binary tree | |
{ | |
int m_nValue; // value of node | |
struct SBinaryTreeNode *m_pLeft; // left child of node | |
struct SBinaryTreeNode *m_pRight; // right child of node | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
// for Linux platform, plz make sure the size of data type is correct for BMP spec. | |
// if you use this on Windows or other platforms, plz pay attention to this. | |
typedef int LONG; | |
typedef unsigned char BYTE; | |
typedef unsigned int DWORD; | |
typedef unsigned short WORD; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# base directory, at top of source tree; replace with absolute path | |
base=`pwd` | |
# configure root dir of interesting stuff | |
root=$base/out/host/linux-x86 | |
export ANDROID_ROOT=$root | |
# configure bootclasspath |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define DECLARE_ENUM(E) struct E { public: E(int value = 0) : _value((__Enum)value) { } E& operator=(int value) { this->_value = (__Enum)value; return *this; } operator int() const { return this->_value; } enum __Enum { | |
#define END_ENUM() }; private: __Enum _value; }; | |
#include <iostream> | |
using namespace std; | |
class B { | |
B &operator=(const B &); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.graphics.PointF; | |
import android.view.animation.Animation; | |
import android.view.animation.Transformation; | |
// http://www.math.ubc.ca/~cass/gfx/bezier.html | |
public class ArcTranslateAnimation extends Animation { | |
private int mFromXType = ABSOLUTE; | |
private int mToXType = ABSOLUTE; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// javap -c -l AutoIncrementDemo | |
Compiled from "AutoIncrementDemo.java" | |
public class AutoIncrementDemo extends java.lang.Object{ | |
public AutoIncrementDemo(); | |
Code: | |
0: aload_0 | |
1: invokespecial #1; //Method java/lang/Object."<init>":()V | |
4: return |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 将数组分三块,中间一块是pivot[就一个元素],左边一块是所有元素都小于pivot,右边一块是所有元素都大于pivot<br /> | |
* 快速排序的基础,简单易懂,居家旅行面试必备 | |
*/ | |
public class ArrayPartition { | |
public static void main(String[] args) { | |
int[] arr = { 4, 5, 3, 22, 1, 3 }; | |
printArray(arr, "init"); | |
System.out.println("pivot idx " + sort(arr, 0, arr.length - 1)); | |
printArray(arr, "result"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ThreadWaitSleepDemo { | |
public static void main(String[] args) { | |
// wait,notify,notifyAll三个方法都有共同点 | |
// The current thread must own this object's monitor. | |
ThreadWaitSleepDemo obj = new ThreadWaitSleepDemo(); | |
new S(obj).start(); | |
try { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.concurrent.CountDownLatch; | |
import org.apache.commons.lang.math.RandomUtils; | |
public class MultipleThreadCalSum { | |
public static void main(String[] args) { | |
final int M = 10000000; // 10万个元素 | |
final int N = 100; // 100个线程 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.xkit.mail.demo; | |
import java.io.UnsupportedEncodingException; | |
import java.net.URLDecoder; | |
import java.util.regex.Matcher; | |
import java.util.regex.Pattern; | |
public class MailAttachmentFilenameDemo { | |
public static void main(String[] args) { |
NewerOlder