建议22:确保集合的线程安全集合线程安全是指多个线程上添加或删除元素时,线程键必须保持同步。下面代码模拟了一个线程在迭代过程中,另一个线程对元素进行了删除。 class Program { static List list = new List() {...
分类:
编程语言 时间:
2015-08-14 18:57:12
阅读次数:
145
Given a linked list, remove the nth node from the end of list and return its head.
For example,
Given linked list: 1->2->3->4->5, and n = 2.
After removing the second node from the end, the...
分类:
其他好文 时间:
2015-08-14 17:06:51
阅读次数:
125
传入网络图片地址就行了public class MyPagerAdapter extends PagerAdapter { private List viewlist;
private Context mContext; public MyPagerAdapter(List viewlist, Context mContext) {...
分类:
其他好文 时间:
2015-08-14 15:45:21
阅读次数:
125
今天因为要用到List的查找功能,所以写了一段测试代码,测试线性查找和二分查找的性能差距,以决定选择哪种查找方式。线性查找:Contains,Find,IndexOf都是线性查找。二分查找:BinarySearch,因为二分查找必须是对有序数组才有效,所以查找前要调用List的Sort方法。结论:如...
分类:
其他好文 时间:
2015-08-14 15:03:20
阅读次数:
91
首先要安装graphviz-dot-mode模块,list-packages的站点国内无法访问,改为手动下载graphviz-dot-model.el,放到~/.emacs.d/目录下。然后修改init.el文件:;; graphviz-dot-model
(load-file "~/.emacs.d/graphviz-dot-model.el")ubutnu系统下要安装graphviz程序,ap...
分类:
系统相关 时间:
2015-08-14 13:54:13
阅读次数:
920
Merge Two Sorted Lists
Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two
lists.
合并两个有序链表
...
分类:
其他好文 时间:
2015-08-14 13:48:23
阅读次数:
86
set集合容器是使用红黑树[一种二叉检索树的数据结构]来组织泛化的元素数据。元素数据的检索使用的是二叉检索树的中序遍历算法,检索的效率高于vector、deque、和list等容器,由于采用中序遍历算法可以将二叉检索树中的键值由小到大遍历出来,所以set集合容器蕴含了元素间的有序性。红黑树的每个节点包含一个取值为红色或者黑色的颜色域,节点键值的插入必须确保树根节点的键值大于左子树所有节点的键值,而小...
分类:
其他好文 时间:
2015-08-14 13:43:47
阅读次数:
274
//学习方法,不要因为一点小问题而导致大技术的学习。//学习方法不在于听,而在做,并坚持。节省时间必须要敲代码。一、Collection 接口(子接口:Set 、 List) ★ Collection体系的共性方法(比特有方法还重要) (1) 【添加】操作 boolean add(Objec...
分类:
其他好文 时间:
2015-08-14 13:40:13
阅读次数:
117
jdk1.8.0_45源码解读——ArrayList的实现一、ArrayList概述 ArrayList是List接口的可变数组的实现。实现了所有可选列表操作,并允许包括 null 在内的所有元素。除了实现 List 接口外,此类还提供一些方法来操作内部用来存储列表的数组的大小。 每个Array.....
分类:
其他好文 时间:
2015-08-14 13:33:44
阅读次数:
215
1.问题未使用泛型时,元素的类型不安全;操作麻烦,可能需要强制转换import java.util.ArrayList;import java.util.List;import org.junit.Test;import day8.Customer;public class GenericTest ...
分类:
其他好文 时间:
2015-08-14 13:21:41
阅读次数:
146