-
链滴是个什么样的社区
2015-11-24 13:41public Set<String> getUserNames(final String text) throws ServiceException { final Set<String> ret = new HashSet<String>(); int idx = text.indexOf('@'); if (-1 == idx) { return ret; } String copy = text.trim(); copy = copy.replaceAll("\\n", " "); copy = copy.replaceAll("(?=\\pP)[^@]", " "); String[] uNames = StringUtils.substringsBetween(copy, "@", " "); String tail = StringUtils.substringAfterLast(copy, "@"); if (tail.contains(" ")) { tail = null; } if (null != tail) { if (null == uNames) { uNames = new String[1]; uNames[0] = tail; } else { uNames = Arrays.copyOf(uNames, uNames.length + 1); uNames[uNames.length - 1] = tail; } } if (null == uNames) { return ret; } for (int i = 0; i < uNames.length; i++) { final String maybeUserName = uNames[i]; if (!UserRegisterValidation.invalidUserName(maybeUserName)) { // A string match the user name pattern if (null != getUserByName(maybeUserName)) { // Found a user ret.add(maybeUserName); copy = copy.replace("@" + maybeUserName, ""); idx = copy.indexOf('@'); if (-1 == idx) { return ret; } } } } return ret; }
完整代码在这里
-
测试代码插入
2015-11-20 11:46package com.dashu; import java.util.ArrayList; import java.util.Comparator; import java.util.List; import java.util.PriorityQueue; import java.util.Queue; import java.util.Random; public class DaShu { static Comparator<Integer> cmp = new Comparator<Integer>() { public int compare(Integer e1, Integer e2) { return e2 - e1; } }; static Queue<Integer> sortQueue = new PriorityQueue<Integer>(10,cmp); public static void main(String[] args) throws Exception { while(true){ Thread.sleep(1000); sortQueue.add(random()); if(sortQueue.size() == 10){ List<Integer> list = new ArrayList<Integer>(); for(int i = 0;i<sortQueue.size();i++){ if(i == 0){ System.out.println("Max :"+sortQueue.poll()); } list.add(sortQueue.poll()); } sortQueue.addAll(list); System.out.println("Min: "+list.get(list.size() - 1)); System.out.println("------------------------------------"); } } } public static int random(){ int max=10000; int min=1; Random random = new Random(); return random.nextInt(max)%(max-min+1) + min; } }
-
welcome to hacpai
2015-11-13 13:54哦,我原以为你用的是独立模式呢,那个模式不用安装数据库、容器,一个命令就可以启动了,是 1.2.0 的最大改进。
对了,有空多来社区看看哦: http://hacpai.com
-
welcome to hacpai
2015-11-13 11:49是 [Solo] ,不是 [B3log] 啦~
另外:
- 你用的是独立模式还是容器模式?还有数据库是 H2 还是 MySQL?
- 1.2.0 还没有正式发布哦,不过应该不会有什么改动了,计划下周发布