Vincent Jia 博客

to be a better man, to be a bad man.

  BlogJava :: 首页 :: 新随笔 :: 联系 :: 聚合  :: 管理 ::
  29 随笔 :: 3 文章 :: 0 评论 :: 0 Trackbacks

2011年12月30日 #

2016年,收获了什么,失去了什么。 
博客没有写作。
国家大事件几多。
posted @ 2017-12-04 16:53 iLinux 阅读(194) | 评论 (0)编辑 收藏

The Collections Framework







The collections framework is a unified architecture for representing and manipulating collections, allowing them to be manipulated independently of the details of their representation. It reduces programming effort while increasing performance. It allows for interoperability among unrelated APIs, reduces effort in designing and learning new APIs, and fosters software reuse. The framework is based on fourteen collection interfaces. It includes implementations of these interfaces, and algorithms to manipulate them.
Overview
  • Overview - An overview of the Collections framework.
API Specification
  • API Reference - An annotated outline of the classes and interfaces comprising the collections framework, with links into the JavaDoc.
Tutorials and Programmer's Guides
  • Tutorial - A tutorial introduction to the collections framework with plenty of programming examples.
API EnhancementsMore Information
  • Design FAQ- Answers to frequently asked questions concerning the design of the collections framework.

From: http://docs.oracle.com/javase/6/docs/technotes/guides/collections/index.html
posted @ 2012-07-06 16:15 iLinux 阅读(250) | 评论 (0)编辑 收藏

API Enhancements

posted @ 2012-07-06 16:14 iLinux 阅读(260) | 评论 (0)编辑 收藏

LinkedHashSet是JDK 1.4中引入的新的集合类(LinkedHashMap也是同期引入)。 LinkedHashSet,顾名思义,就是在Hash的实现上添加了Linked的支持。对于LinkedHashSet,在每个节点上通过一个链表串联起来,这样,就可以保证确定的顺序。对于希望有常量复杂度的高效存取性能要求、同时又要求排序的情况下,可以直接使用LinkedHashSet。

它实现了Set接口。存入Set的每个元素必须是唯一的,因为Set不保存重复元素。但是Set接口不保证维护元素的次序(那里面的元素每次顺序如何确定?TODO)。Set与Collection有完全一样的接口Iterable,同时Set继承了Collection。

LinkedHashSet具有HashSet的查询速度,且内部使用链表维护元素的顺序(插入的顺序),于是在使用迭代器便利Set时,结果会按元素插入的次序显示。

需求如: 含多个(有重复)元素ArrayList,去除重复。

1, 可以使用如下略显冗余的代码:
 1 public static List removeDuplicateWithOrder(List list) {
 2         Set set = new HashSet();
 3         List newList = new ArrayList();
 4         for (Iterator iter = list.iterator(); iter.hasNext();) {
 5             Object element = iter.next();
 6             if (set.add(element))
 7                 newList.add(element);
 8         }
 9         return newList;
10     }
此方法有滥用set之嫌。

2, 我们也可以使用本文章中提及的LinkedHashSet:
return new ArrayList<T>(new LinkedHashSet<T>(list));
此方法,既利用set去除了重复,又使用linked保持住了原顺序。

3, 貌似apache commons lang中有专门去重复的集合工具。

这儿的链表操作是常量级的,这也是LinkedHashSet/LinkedHashMap比TreeSet/TreeMap性能更高的原因。当然,LinkedHashSet不是thread-safe的,在多线程环境下,需要进行同步包装:
Collections.synchronizedCollection(Collection);
or:
Collections.synchronizedSet(Set);
在使用LinkedHashSet的iterator()方法遍历元素时,如果其他线程有读取操作,也要进行同步,否则,就会抛出同其它fail-fast一样的由于删除或增加操作而引起的CurrentModificationException。


如上两种方法的效率比较,设为TODO,
1, 利用set.add(element)方法,本质是利用其contains()方法判断,而contains()的本质就是遍历。
JDK doc中写道:
More formally, adds the specified element e to this set if the set contains no element e2 such that (e==null ? e2==null : e.equals(e2)). If this set already contains the element, the call leaves the set unchanged and returns false. In combination with the restriction on constructors, this ensures that sets never contain duplicate elements.
2, 测试数据,可以使用数据量:1W,5W,10W,100W。

posted @ 2012-07-06 11:54 iLinux 阅读(6193) | 评论 (0)编辑 收藏

在当前的系统中,大量使用了非泛型模式的Collection、List、Map、HashMap、HashTable。
其关系、区别在于。
posted @ 2012-06-29 17:50 iLinux 阅读(239) | 评论 (0)编辑 收藏

在美国得克萨斯州的一个风雪交加的夜晚,一位名叫克雷斯的年轻人因为汽车“抛锚”被困在郊外。正当他万分焦急的时候,有一位骑马的男子正巧经过这里。见此情景,这位男子二话没说便用马帮助克雷斯把汽车拉到了小镇上。 事后,当感激不尽的克雷斯拿出不菲的美钞对他表示酬谢时,这位男子说:“这不需要回报,但我要你给我一个承诺,当别人有困难的时候,你也要尽力帮助他人。”于是,在后来的日子里,克雷斯主动帮助了许许多多的人,并且每次都没有忘记转述那句同样的话给所有被他帮助的人。 许多年后的一天,克雷斯被突然暴发的洪水困在了一个孤岛上,一位勇敢的少年冒着被洪水吞噬的危险救了他。当他感谢少年的时候,少年竟然也说出了那句克雷斯曾说过无数次的话:“这不需要回报,但我要你给我一个承诺……” 克雷斯的胸中顿时涌起了一股暖暖的激流:“原来,我穿起的这根关于爱的链条,周转了无数的人,最后经过少年还给了我,我一生做的这些好事,全都是为我自己做的!”  当您有幸看到此消息时,请转发给自己的朋友亲人。我相信有更多的人需要我们的帮助, 正义会传染 邪恶也是如此, 为现在的别人做善事也是为了将来的自己。
传递温暖,拒绝冷漠。
  1、如果钱还宽裕,别养二奶,偷偷养几个贫困山区的学生,你心里一定会觉得舒坦;
  2、遇到夜里摆地摊的,能买就多买一些,别还价,东西都不贵。家境哪怕好一点,谁会大冷天夜里摆地摊;
    遇到学生出来勤工俭学的,特别是中学生、小姑娘,她卖什么你就买点。如果她不是家庭困难,出来打工也需要勇气的,鼓励鼓励她吧;   
  3、捡到钱包就找找失主。如果你实在缺钱就把现金留下,打电话告诉失主就说你在厕所里捡到的。把信用卡、身份证、驾驶执照还给人家,一般别人也不会在乎钱了。把人家的地址记在你的笔记本上,以后发达了去找人家道个歉,把钱还给人家;   
  4、遇到问路的,碰巧你又知道那个地址,就主动告诉一声。别不好意思,没有人笑话你;    
  5、如果丢的垃圾里有碎玻璃、大头针、刀片等,请用胶带把它们缠裹一下,并尽量多缠几层。这样就降低了保洁人员或者捡垃圾者被伤害的概率。他们大都是没有医保的弱势群体,体贴体贴他们吧,好人会有好报的。
  6、遇到迷路的小孩和老头老太,能送回家送回家,不能送回家的送上车、送到派出所也行。替老人或小孩打个电话再走,反正你也不缺那两个电话费;    
  7、雨雪的时候、天冷的傍晚,遇到卖菜的、卖水果的,剩的不多了又不能回家,能全买就全买,不能全买就买一份,反正吃什么也是吃,买下来让人早点回家;   
  8、上车遇到老弱病人、孕妇,让座的时候别动声色,也别大张旗鼓。站起来用身体挡住其他人,留出空位子给需要的人,然后装作下车走远点。人太多实在走不远,人家向你表示谢意的时候微笑一下;   
  9、不要对有精神信念的人用猥亵言词,要知道中国人缺就缺在没有信仰。这世界什么都在变,什么都不可全信,唯有信念不变、不动、永恒;   
  10、如果您的时间还宽裕,把这几句话转几个群,网上很多人看,转了心里舒坦。
  11、一般情况,看完这段文章而且主动到各个群里转发的人,都还是遗留着传统美德的中国好人
posted @ 2012-06-27 23:08 iLinux 阅读(232) | 评论 (0)编辑 收藏

在文章http://www.blogjava.net/aoxj/archive/2012/06/16/380926.html中,看到案例,++符号并不是原子操作,
posted @ 2012-06-27 23:08 iLinux 阅读(217) | 评论 (0)编辑 收藏

李小龙传奇 - 15 Kick-ass Bruce Lee quotes
http://www.slideshare.net/thepresentationdesigner/15-kickass-bruce-lee-quotes
posted @ 2012-06-25 17:33 iLinux 阅读(211) | 评论 (0)编辑 收藏

OoO
http://www.bbc.co.uk/worldservice/learningenglish/language/wordsinthenews/2011/08/110803_witn_korea.shtml
http://developer.51cto.com/col/461/
http://www.google.com/search?q=runtimeexception&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:zh-CN:official&client=firefox-a#sclient=psy&hl=en&client=firefox-a&rls=org.mozilla:zh-CN%3Aofficial&source=hp&q=spring3+%E5%BC%82%E5%B8%B8%E5%A4%84%E7%90%86&pbx=1&oq=spring3+%E5%BC%82%E5%B8%B8%E5%A4%84%E7%90%86&aq=f&aqi=&aql=&gs_sm=e&gs_upl=316376l316376l4l316608l1l1l0l0l0l0l0l0ll0l0&fp=1&biw=1280&bih=769&bav=on.2,or.r_gc.r_pw.,cf.osb&cad=b
http://www.infoq.com/cn/news/2011/01/git-adventures-1
http://www.kernel.org/pub/software/scm/git/docs/gittutorial.html
http://www.linuxeden.com/forum/thread-191912-1-1.html
http://books.slashdot.org/story/04/11/12/2042249/How-Tomcat-Works
http://static.springsource.org/spring/docs/3.1.0.M2/spring-framework-reference/html/orm.html#orm-hibernate
http://stackoverflow.com/questions/tagged/spring?sort=faq&pagesize=15
http://xiaolinjava.iteye.com/blog/684292
http://www.donews.com/original/201112/1011333.shtm
http://www.readwriteweb.com/archives/top_10_social_web_products_of_2011.php
http://www.readwriteweb.com/archives/the_10_biggest_web_news_stories_of_2011.php
http://blog.csdn.net/buoll/article/details/1851149
http://www.blogjava.net/masen/articles/118701.html
http://www.baidu.com/s?bs=org.springframework.jdbc.datasource.DriverManagerDataSource&f=8&rsv_bp=1&wd=tomcat+jndi&inputT=2640
http://home.51.com/xiaohei267/diary/item/10048051.html
http://blog.csdn.net/wzl002/article/details/5969635
http://www.baidu.com/s?bs=spring+controller+%D7%AA%B7%A2&f=8&rsv_bp=1&wd=spring+3.0+%B4%EE%BD%A8&inputT=7004
http://book.ifeng.com/lianzai/detail_2010_08/25/2309143_11.shtml
http://www.learnamericanenglishonline.com/
http://bulo.hjenglish.com/app/menu/558/
http://bulo.hjenglish.com/menu/zzk?langs=en
posted @ 2011-12-30 15:46 iLinux 阅读(283) | 评论 (0)编辑 收藏

沃夏克的《自新大陆交响曲》 卡拉扬指挥



posted @ 2011-12-30 03:45 iLinux 阅读(188) | 评论 (0)编辑 收藏