博文

sliksvn多语言导致乱码问题的解决办法

如果在英文windows上装了sliksvn但是又把控制面板里Region and language options其中advanced页设成了中文。控制台里svn总是输出乱码,这时候打开sliksvn安装目录,把share目录改名,再输入svn命令,一切正常。

Java中的Dynamic Proxy 动态代理

图片
Dynamic Proxy是这样一种class:它是在运行时生成的class,在生成它时你必须提供一组interface给它,然后该class就宣称它实现了这些 interface。你当然可以把该class的实例当作这些interface中的任何一个来用。当然啦,这个Dynamic Proxy其实就是一个Proxy,它不会替你作实质性的工作,在生成它的实例时你必须提供一个handler,由它接管实际的工作     。  动态代理的定义: 一个动态代理类在运行期implements一组interface,使得interface实现类的方法调用被分派至其他的类(另外的interface实现类或者任意的类)的方法 。 讲得更通俗一些,要了解动态代理,我们就要知道什么东西动态了,代理了什么?首先,一个Proxy代理了一组interface的方法。注意, 代理的是interface ,而不是Class,也不是abstract Class;其次, Proxy具有的型别由绑定的interface所决定的 ,动态就体现在此。 public   interface  Resource  {      public   void  operationA();      public   void  operationB(); }                                                  public   class  Concret...

Short introduction to BASE64

BASE64算法是一个常见的加密算法,可以实现对文本的加密,据说还可以将二进制的文件转换成文本文件,通常电脑中的所有的文件都是以二进制流的形式存 储在硬盘上的,这样一来,也许所有的文件都可以转换为文本了吧:)!不管怎么说,其转换的算法都是想同的,下面以简单的ASCII文本为例,介绍一下 BASE64算法的转换过程!     我们知道通常的计算机系统当中,一个字节是由8个二进制位组成的,例如“A”的ASCII编码值是十进制数的65,转换成二进制数就是 “01000001”,而BASE64算法就是在这样的二进制的基础上进行编码的。算法首先取3个字节的数据,转换成二进制,我们就用可爱的企鹅举个例子 吧:         “TUX” 转换成二进制:         “01010100 01010101 01011000” 注意:这里每个字节间的空格实际上是不存在的 这样我们就得到了8*3=24个二进制位组成的序列,然后再将这24个位每6个分一组,分成24/6=4组:         “010101 000101 010101 011000” 将这四个分组高位补零,形成可以转换为一个字节的8位:         “00010101 00000101 00010101 00011000” 再将这四个字节转换成十进制数:         “21 5 21 24” 接下来我们要构建一个编码表:         0    A     17 R     34 i     51 z ...

Master theorem 主定理及其应用算法

图片
Generic form The master theorem concerns recurrence relations of the form: In the application to the analysis of a recursive algorithm, the constants and function take on the following significance: n  is the size of the problem. a  is the number of subproblems in the recursion. n / b  is the size of each subproblem. (Here it is assumed that all subproblems are essentially the same size.) f  ( n ) is the cost of the work done outside the recursive calls, which includes the cost of dividing the problem and the cost of merging the solutions to the subproblems. Application to common algorithms Algorithm Recurrence Relationship Run time Comment Binary search O (log( n )) Apply Master theorem where  f ( n ) =  n c [3] Binary tree traversal O ( n ) Apply Master theorem where  f ( n ) =  n c [3] Optimal Sorted Matrix Search O ( n ) Apply  Akra-Bazzi theorem  for  p  = 1  and  g ( u ) = log( u ) ...