- 博客(135)
- 收藏
- 关注
原创 String源码分析(4)--浅析String中的静态工厂
本文基于JDK1.8在方法篇中我们有对String类中的构造方法进行了一个分析,对于类而言,为了让客户端(即类的使用者)获取它自身的一个实例,除了上篇文章写的提供一个公有的构造器,还有一种管理对象创建的方法:类可以提供一个公有的静态工厂方法(static factory method),即一个返回类的实例的静态方法。本篇文章将通过String中的valueOf()方法,谈一谈静态工厂方法的...
2019-05-04 22:02:50
320
原创 String源码剖析(3)--方法篇
本文基于JDK1.8本篇文章主要是关于String类的内部方法的分析,目录如下:构造函数分析“比较”方法String对“+”的重载构造函数分析1.默认构造函数public String() { this.value = "".value;}该构造方法会创建空的字符序列,注意这个构造方法的使用,因为创造不必要的字符串对象是不可变的。因此不建议采取下面的创建 Stri...
2019-05-03 18:10:21
369
原创 String源码剖析(2)--浅析String类
本文基于JDK1.8上篇文章学习了String中的哈希值的作用,本篇开始正式进入String类。文章将按以下几块展开。从类的声明看其不可变性成员变量是为何关于内部方法将在下一篇文章中详解,话不多说,进入正题。从类的声明看其不可变性String作为Java最基本最常用的类,我们应当对其内部实现有一个清晰的了解。先看String类的定义:public final clas...
2019-05-03 18:09:00
336
原创 String源码剖析(1)--哈希篇
本文基于JDK1.8让我们从一段代码开始System.out.println("a" + "b" == "ab");System.out.println(new String("ab") == "ab");上述代码中,第一行结果为True,第二行结果为False。两者结果不同的原因在于Java中的==符号判断的是对象是否相等,其实质上是比较两者的内存地址,很显然第一行两...
2019-05-03 18:08:01
296
原创 解决Maven等情景连接url时报错Server returned HTTP response code: 407 for URL
maven编译过程中,下载不了项目依赖的pom文件和jar包。在确认代理已经配置正确的情况下仍然出现Server returned HTTP response code: 407 for URL的错误。可以参考以下方案解决:清除maven的代理,尝试编译。所需下载的文件是否可以用wget命令下载:wget <filename>如果wget命令下载不了,请确认代理是否正确...
2018-11-12 18:55:06
5199
原创 gradle缓存库转成maven
简书地址:https://www.jianshu.com/p/050dd9fc2438gradle缓存库转成maven一般有以下情况:在将用gradle管理的代码上库时,由于CI库上的项目编译需要本地化,且只支持maven的依赖缓存的文件结构。会出现gradle找不到包,无法编译的情况。maven的依赖库中有许多第三方的依赖包,用gradle直接查找maven库,免去单独设置代理的繁琐...
2018-10-23 19:45:20
1600
原创 git命令记录
简书地址:https://www.jianshu.com/p/b4b0b0aa7e08不同于熟知的SVN,CC等集中式的版本控制工具,Git是一款开源的分布式版本控制系统。基本概念工作拷贝(工作目录):用于存放产品开发数据本地工作目录索引(Index):用于存放待提交数据的缓存区本地库:远端库的一个完整的拷贝,包括所有文件的修改记录,分支等。远端库:本地库clone来源中心库:远...
2018-10-23 19:43:57
214
原创 [String源码]Java String.split()源码分析
今天遇到了String.split()方法,结合源码分析、记录下(最后附上正则表达式记录):简介split(String regex, int limit)一般根据正则表达式分割字符串,limit限定分割后的子字符串个数,超过数量限制的情况下前limit-1个子字符串正常分割,最后一个子字符串包含剩下所有字符。重载方法split(String regex)将limit设置为0。 pub...
2018-10-09 09:08:34
1295
原创 VS2015 LoadLibrary加载DLL失败的解决方案,GetLastError()返回值193
遇到的问题代码如下void *p=NULL;p=LoadLibrary("***.dll");通过单步调试发现,p的值始终为0X00000000,即LoadLibrary调用失败 查了很多资料,将总结以及我的解决方案记录如下检查路径是否正确。我用的是相对路径,相对路径需要把该dll文件放在程序生成的exe文件目录下(也就是VS中 项目->属性->(配置属性)常...
2018-04-25 14:40:16
16335
原创 剑指offer:二叉搜索树与双向链表非递归与递归解法
题目输入一棵二叉搜索树,将该二叉搜索树转换成一个排序的双向链表。要求不能创建任何新的结点,只能调整树中结点指针的指向。解析主要利用中序便利,通过设置一个结点变量记录前一个结点进行变换 需熟练掌握树中序遍历的递归与非递归写法代码非递归,主要利用栈/*struct TreeNode { int val; struct TreeNode *left; struct TreeNo
2018-01-05 09:32:39
497
原创 61. Rotate List
题目Given a list, rotate the list to the right by k places, where k is non-negative.Example:Given 1->2->3->4->5->NULL and k = 2,return 4->5->1->2->3->NULL.解析题意是让旋转一个链表,一开始想到的是快慢指针,但是实现之后发现十分的麻烦,有许多指针移动的操
2017-12-17 16:05:27
178
原创 Weekly Contest 63
Min Cost Climbing StairsShortest Completing WordNumber Of Corner RectanglesContain Virus746. Min Cost Climbing Stairs 难度:esayOn a staircase, the i-th step has some non-negative cost cost[i] assig
2017-12-17 12:57:27
372
原创 57. Insert Interval
题目Given a set of non-overlapping intervals, insert a new interval into the intervals (merge if necessary).You may assume that the intervals were initially sorted according to their start times.Example
2017-12-16 12:37:30
210
原创 56. Merge Intervals
题目Given a collection of intervals, merge all overlapping intervals.For example, Given [1,3],[2,6],[8,10],[15,18], return [1,6],[8,10],[15,18].解析题意:将一个Interval新结构进行合并 关键点在于每次比较用的是ret中的尾Interval。代码/**
2017-12-16 12:06:46
229
原创 50. Pow(x, n)
题目Implement pow(x, n).Example 1:Input: 2.00000, 10 Output: 1024.00000 Example 2:Input: 2.10000, 3 Output: 9.26100解析题意:实现幂运算 分析:主要考察利用二分降低运算时间复杂度,注意当n=INT_MIN时的边界处理,INT_MIN的绝对值比INT_MAX的绝对值大一代码class
2017-12-12 22:48:44
253
原创 49. Group Anagrams
题目Given an array of strings, group anagrams together.For example, given: [“eat”, “tea”, “tan”, “ate”, “nat”, “bat”], Return:[ ["ate", "eat","tea"], ["nat","tan"], ["bat"] ] Note: All input
2017-12-12 22:40:03
176
原创 47. Permutations II
题目Given a collection of numbers that might contain duplicates, return all possible unique permutations.For example, [1,1,2] have the following unique permutations: [ [1,1,2], [1,2,1], [2,1,1
2017-12-12 22:05:55
191
原创 43. Multiply Strings
题目Given two non-negative integers num1 and num2 represented as strings, return the product of num1 and num2.Note:The length of both num1 and num2 is < 110. Both num1 and num2 contains only digits 0-9.
2017-12-11 22:45:34
221
原创 42. Trapping Rain Water
题目Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining.For example, Given [0,1,0,2,1,0,1,3,2,1,2,1], r
2017-12-11 22:14:23
187
原创 优快云-markdown语法
欢迎使用Markdown编辑器写博客本Markdown编辑器使用StackEdit修改而来,用它写博客,将会带来全新的体验哦:Markdown和扩展Markdown简洁的语法代码块高亮图片链接和图片上传LaTex数学公式UML序列图和流程图离线写博客导入导出Markdown文件丰富的快捷键快捷键加粗 Ctrl + B 斜体 Ctrl + I 引用 Ctrl
2017-12-10 18:22:21
170
原创 37. Sudoku Solver
题目Write a program to solve a Sudoku puzzle by filling the empty cells.Empty cells are indicated by the character ‘.’.You may assume that there will be only one unique solution. A sudoku puzzle… …and
2017-12-10 10:45:32
176
原创 36. Valid Sudoku
题目Determine if a Sudoku is valid, according to: Sudoku Puzzles - The Rules.The Sudoku board could be partially filled, where empty cells are filled with the character ‘.’.A partially filled sudoku whic
2017-12-09 16:21:26
160
原创 虚函数总结
1、静态函数不可以是虚函数因为静态成员函数没有this,也就没有存放vptr的地方,同时其函数的指针存放也不同于一般的成员函数,其无法成为一个对象的虚函数的指针以实现由此带来的动态机制。静态是编译时期就必须确定的,虚函数是运行时期确定的。 虚函数的主要意义在于多态(包括静态多态与动态多态,静态体现在模板方面,动态体现在虚函数方面),动态多态体现在动态绑定,然而构造时动态类型都没有完整。 虚函数的
2017-12-08 17:08:31
380
原创 基于c++11的100行实现简单线程池
背景刚粗略看完一遍c++ primer第五版,一直在找一些c++小项目练手,实验楼里面有很多项目,但是会员太贵了,学生党就只能google+github自行搜索完成项目了。注:本文纯提供自己的理解,代码完全照抄,有想法的欢迎评论留言一起讨论。本文参考:c++11线程池实现A simple C++11 Thread Pool implementation涉及到的c++11的特性:std::ve
2017-12-08 12:10:08
23171
8
原创 10. Regular Expression Matching
Implement regular expression matching with support for '.' and '*'.'.' Matches any single character.'*' Matches zero or more of the preceding element.The matching should cover the entire input st
2017-11-29 11:42:10
153
原创 0-1背包打印路径
#include#include#includeusing namespace std;void bag(int V,vector &cost,vector &w){ int i,v; vector dp(V+1,0); vector> path(10,vector(10)); dp[0]=0; for( i=1;i<=cost.size();i+
2017-11-28 15:57:06
651
原创 5. Longest Palindromic Substring
Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000.Example:Input: "babad"Output: "bab"Note: "aba" is also a valid answer.
2017-11-27 18:34:38
184
原创 xcode IOS开发中如何让APP的不同版本共存于设备上
简单修改下工程的Genneral设置即可,版本相关Xcode 9.1Build version 9B55如图,修改Bundle Identifier即可,如test,test-beta,而Display Name是用来在设备中区别两个应用的应用名
2017-11-27 10:38:16
2390
原创 3. Longest Substring Without Repeating Characters
Given a string, find the length of the longest substring without repeating characters.Examples:Given "abcabcbb", the answer is "abc", which the length is 3.Given "bbbbb", the answer is "
2017-11-25 19:50:12
164
原创 2. Add Two Numbers
You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return
2017-11-25 19:03:42
159
原创 147. Insertion Sort List
Sort a linked list using insertion sort.画个图一目了然/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL)
2017-11-22 10:20:43
143
原创 143. Reorder List
Given a singly linked list L: L0→L1→…→Ln-1→Ln,reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→…You must do this in-place without altering the nodes' values.For example,Given {1,2,3,4}, reorder it to {1,4
2017-11-21 18:05:12
153
原创 140. Word Break II
Given a non-empty string s and a dictionary wordDict containing a list of non-empty words, add spaces in s to construct a sentence where each word is a valid dictionary word. You may assume the dict
2017-11-21 16:39:37
239
原创 139. Word Break
Given a non-empty string s and a dictionary wordDict containing a list of non-empty words, determine if s can be segmented into a space-separated sequence of one or more dictionary words. You may as
2017-11-21 15:20:22
159
原创 138. Copy List with Random Pointer
A linked list is given such that each node contains an additional random pointer which could point to any node in the list or null.Return a deep copy of the list.同之前的那个clone graph 133.
2017-11-21 11:51:03
145
原创 135. Candy
There are N children standing in a line. Each child is assigned a rating value.You are giving candies to these children subjected to the following requirements:Each child must have at least one
2017-11-21 10:47:21
141
原创 133. Clone Graph
Clone an undirected graph. Each node in the graph contains a label and a list of its neighbors.OJ's undirected graph serialization:Nodes are labeled uniquely.We use # as a separator for each
2017-11-20 17:57:52
219
原创 131. Palindrome Partitioning && 132. Palindrome Partitioning II
Given a string s, partition s such that every substring of the partition is a palindrome.Return all possible palindrome partitioning of s.For example, given s = "aab",Return[ ["aa","b"],
2017-11-20 15:12:07
189
原创 128. Longest Consecutive Sequence
Given an unsorted array of integers, find the length of the longest consecutive elements sequence.For example,Given [100, 4, 200, 1, 3, 2],The longest consecutive elements sequence is [1, 2, 3,
2017-11-19 12:19:15
149
原创 119. Pascal's Triangle II
Given an index k, return the kth row of the Pascal's triangle.For example, given k = 3,Return [1,3,3,1].Note:Could you optimize your algorithm to use only O(k) extra space?首先思考
2017-11-19 10:29:09
179
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人