摘要:
1.单线程实现package com.mime; import java.io.File; public class TotalFileSizeSequential { private long getTotalSizeOfFilesInDir(final File file) { if (file.isFile()) return file.length(); final File[] children = file.listFiles(); long total = 0; if (children != null) for (final File chil... 阅读全文
摘要:
我们先看下面一个示例 public class RaceCondition { private static boolean done; public static void main(final String[] args) throws InterruptedException { new Thread(new Runnable() { public void run() { int i = 0; while (!done) { i++; } System.out.println("Done!"); } }).start... 阅读全文
摘要:
public abstract class AbstractPrimeFinder { public boolean isPrime(final int number) { if (number <= 1) return false; for (int i = 2; i <= Math.sqrt(number); i++) if (number % i == 0) return false; return true; } public int countPrimesInRange(final int lower, final int upper) { ... 阅读全文
摘要:
字典树查找,Trie,又称字典树、单词查找树,是一种树形结构,用于保存大量的字符串。它的优点是:利用字符串的公共前缀来节约存储空间。package com.jwetherell.algorithms.data_structures; import java.util.Arrays; /** * A trie, or prefix tree, is an ordered tree data structure that is used to * store an associative array where the keys are usually strings. * * =... 阅读全文
摘要:
区间树可以统计某个区间对应的重复的区间package com.jwetherell.algorithms.data_structures; import java.security.InvalidParameterException;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import java.util.TreeSet; /** * An interval tree ... 阅读全文
摘要:
1.到这里下载apache的最新版2.4.3http://httpd.apache.org/download.cgi#apache242.先安装apache需要的几个模块下载所需软件包:
wget http://archive.apache.org/dist/apr/apr-1.4.5.tar.gz wget http://archive.apache.org/dist/apr/apr-util-1.3.12.tar.gz wget http://jaist.dl.sourceforge.net/project/pcre/pcre/8.10/pcre-8.10.zip 具体步骤如下... 阅读全文
摘要:
最近重新学习数据结构和算法,刚刚看完java版的这几个数据结构,比较浅显易懂,有兴趣的可以自己去调试学习,关于这几个的介绍网上很多。二叉搜索树,比较简单的树结构了package com.jwetherell.algorithms.data_structures; import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import java.util.Queue; /** * A binary search tree (BST), wh... 阅读全文
摘要:
1.到mysql网站下载mysql cluster版本http://www.mysql.com/downloads/cluster/ 下载到/home/weijianzhongwj/software下2.安装mysql clustercd /home/weijianzhongwj/software tar xvfmysql-cluster-gpl-7.2.8-linux2.6-i686.tar.gz ln -smysql-cluster-gpl-7.2.8-linux2.6-i686 mysqlc在$HOME/.bashrc增加 export PATH=$PATH:/home/weijianz 阅读全文
摘要:
我使用的ubutun,安装用apt-get非常方便。weijianzhongwj@ubuntu:~$ dstat
You did not select any stats, using -cdngy by default.
----total-cpu-usage---- -dsk/total- -net/total- ---paging-- ---system--
usr sys idl wai hiq siq| read writ| recv send| in out | int csw 16 5 77 2 0 1| 181k 147k| 0 ... 阅读全文
摘要:
public OfferInfo parseXml(String content) throws NumberFormatException, XMLStreamException { if (content == null || content.isEmpty()) { return null; } XMLInputFactory factory = XMLInputFactory.newInstance(); XMLStreamReader reader = null; try ... 阅读全文