- 博客(18)
- 资源 (2)
- 收藏
- 关注
原创 Java集合(14)——AbstractQueue源码解析
类图官方文档(1)该类的add()、remove()和element()方法依赖于offer()、poll()和peek()方法,因此使用该类的类需要实现Queue接口的于offer()、poll()和peek()方法 (2)当队列中元素为null时,抛出异常,而不是返回false或null (3)每一个实现Queue接口并继承AbstractQueue类的类必须定义offer...
2018-03-25 11:14:35 326
原创 Leetcode——38. Count and Say
题目原址https://leetcode.com/problems/count-and-say/description/题目描述The count-and-say sequence is the sequence of integers with the first five terms as following: 1 11 21 1211 111221...
2018-03-24 19:35:14 186
原创 Leetcode——434. Number of Segments in a String
题目原址https://leetcode.com/problems/number-of-segments-in-a-string/description/题目描述Count the number of segments in a string, where a segment is defined to be a contiguous sequence of non-space cha...
2018-03-24 18:54:32 162
原创 Leetcode——459. Repeated Substring Pattern
题目原址https://leetcode.com/problems/repeated-substring-pattern/description/题目描述Given a non-empty string check if it can be constructed by taking a substring of it and appending multiple copies of ...
2018-03-24 17:50:50 133
原创 Java集合(13)——Queue与Deque源码解析
Queue类图Queue官方文档Queue成员方法Deque类图Deque官方文档Deque成员方法(1)–(14)是Deque自己的方法 (15)–(20)是Queue中的方法 (21)–(22)是Stack中的方法 (23)–(27)是Collection中的方法...
2018-03-24 16:35:06 221
原创 Java集合(12)——TreeSet源码解析
类图官方文档TreeSet类实现了NavigableSet接口,因此它是有顺序的Set类,可以指定一个顺序,在元素存入时,按照指定的顺序排序其中排序的顺序有两种方式:自然排序和比较器排序自然排序 TreeSet类的add()方法中会把存入的对象提升为Comparable类型调用对象的compareTo()方法和集合中的对象比较根据compareTo()方法返回的结果进行...
2018-03-24 16:08:29 421
原创 Java集合(11)——EnumSet源码解析
类图官方文档(1)EnumSet是一个专为枚举类型设计的类,EnumSet中的所有元素都必须是指定枚举类型的枚举值 (2)EnumSet在内部以位向量的形式进行存储,对于一些批量操作,如containsAll and retainAll,如果其参数是EnumSet类型,则该批量操作的执行速度会很快 (3)通过使用iterator迭代器,可以实现集合中元素的存储顺序与插入元素时的...
2018-03-24 14:06:49 258
原创 Java集合(10)——HashSet源码解析
类图官方文档成员变量成员方法成员方法源码解析1. public HashSet()方法 public HashSet() { map = new HashMap<>(); }源码解析:功能:无参构造函数源码思路:构造一个新的,空的HashMap实例,它有默认的初始化容量,容量为16,负载数为0.75...
2018-03-24 11:13:42 300
原创 Leetcode——387. First Unique Character in a String
题目原址https://leetcode.com/problems/first-unique-character-in-a-string/description/题目描述Given a string, find the first non-repeating character in it and return it’s index. If it doesn’t exist, retu...
2018-03-23 14:22:54 169
原创 Leetcode——383. Ransom Note
题目原址https://leetcode.com/problems/ransom-note/description/题目描述Given an arbitrary ransom note string and another string containing letters from all the magazines, write a function that will retur...
2018-03-23 13:40:34 201
原创 LeetCode—— 13. Roman to Integer
题目原址https://leetcode.com/problems/roman-to-integer/description/题目描述Given a roman numeral, convert it to an integer. Input is guaranteed to be within the range from 1 to 3999.解题思路罗马数字一共有7个字母...
2018-03-23 13:12:47 159
原创 Leetcode——696. Count Binary Substrings
题目原址https://leetcode.com/problems/count-binary-substrings/description/题目描述Give a string s, count the number of non-empty (contiguous) substrings that have the same number of 0’s and 1’s, and all...
2018-03-23 12:02:21 333
原创 Leetcode——788. Rotated Digits
题目原址https://leetcode.com/problems/rotated-digits/description/题目描述X is a good number if after rotating each digit individually by 180 degrees, we get a valid number that is different from X. Eac...
2018-03-23 11:26:49 774
原创 Leetcode——520. Detect Capital
题目原址https://leetcode.com/problems/detect-capital/description/题目描述Given a word, you need to judge whether the usage of capitals in it is right or not. We define the usage of capitals in a wor...
2018-03-23 10:40:39 165
原创 Leetcode——521. Longest Uncommon Subsequence I
题目原址https://leetcode.com/problems/longest-uncommon-subsequence-i/description/题目描述Given a group of two strings, you need to find the longest uncommon subsequence of this group of two strings. The...
2018-03-23 10:29:35 168
原创 java集合(9)——AbstractSet源码解析
类图官方文档AbstractSet成员方法1. protected AbstractSet()构造方法 protected AbstractSet() { }2. public boolean equals(Object o)方法 public boolean equals(Object o) { if...
2018-03-22 15:40:17 437
原创 Java集合(8)——ArrayList源码解析
类图官方文档ArrayList成员变量ArrayList构造函数ArrayList内部类ArrayList成员方法 ArrayList成员方法源码解析1. public ArrayList(int initialCapacity)带参构造方法 public ArrayList(int initialCa...
2018-03-22 13:32:02 624
原创 Java集合(7)——LinkedList源码解析
类图官方文档LinkedList成员变量LinkedList构造函数LinkedList内部类LinkedList成员方法 LinkedList链表尽管数组在连续的存储位置上存放对象的引用,但链表却将每个对象存放在独立的结点中。每个结点还存放着序列中喜爱个结点的引用。在Java程序设计语言中,所有链表实际上都是双向链...
2018-03-21 13:28:43 250
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人