自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(54)
  • 收藏
  • 关注

原创 购物车逻辑

今天是双十一光棍节,先祝自己节日快乐。。。。大家伙剁手了没,给马云爸爸做了多大贡献啊借着今天购物狂欢的东风,我就来说说实现购物车的代码逻辑。。。addCart(...)//将商品添加到购物车,存商品{1、取出Cookies,遍历Cookies取出购物车_buyerCart;2、不管_buyerCart是否为空(空就新建一个),将商品_CartItem加入购物

2017-11-11 23:50:15 294

原创 安装zookeeper(单机)

1 上传:我使用secureFX 上传到目录 /root2  解压:tar -zxvf  zookeeper-3.4.6.tar.gz  -C /usr/local/src3  目录结构:关注bin、conf两个目录即可4  配置配置文件:复制模板即可,cp  zoo_sample.cfg  zoo.cfg5  启动: ./zkServer.sh  start6  查看状态:.

2017-09-02 23:00:33 235

原创 wordBreak-ii

Given a string s and a dictionary of words dict, add spaces in s to construct a sentence where each word is a valid dictionary word.Return all such possible sentences. For example, givens ="ca

2017-08-20 19:10:49 318

原创 word-break

Given a string s and a dictionary of words dict, determine if s can be segmented into a space-separated sequence of one or more dictionary words.For example, givens ="leetcode",dict =["leet",

2017-08-16 23:03:24 207

原创 linked-list-cycle-ii

Given a linked list, determine if it has a cycle in it. Follow up:Can you solve it without using extra space? public class LinkedListCycle {    //节点数据结构    static class ListNode     {

2017-07-30 19:41:38 183

原创 linked-list-cycle

Given a linked list, return the node where the cycle begins. If there is no cycle, return null.Follow up:Can you solve it without using extra space? 思路: 1)使用快慢指针方法,判定是否存在环,并记录两指针相遇位置(Z);

2017-07-17 22:17:09 177

原创 reorder-list

Given a singly linked list L: L 0→L 1→…→Ln-1→L n,reorder it to: L 0→L n →L1→L n-1→L 2→Ln-2→… You must do this in-place without altering the nodes' values. For example,Given{1,2,3,4}, reo

2017-06-30 23:29:07 182

原创 二叉树的先序遍历BTPreorderTraversal

public class BTPreorderTraversal {    //节点数据结构    static class TreeNode     {        int val;        TreeNode left;        TreeNode right;        TreeNode(int x)         {      

2017-06-20 22:28:27 325

原创 二叉树的后序遍历BTPostorderTraversal

/* * 后序遍历二叉树 * 核心思想是用栈做辅助空间,先从根节点往左一直入栈,直到为空,然后判断栈顶元素的右孩子, * 如果为空或被访问过,说明此时栈顶为要访问的节点,出栈然后访问即可; * 否则从它开始重复左孩子入栈的过程,接下来再判断栈顶元素的右孩子...直到栈空。 */public class BTPostorderTraversal {    static

2017-06-11 21:07:43 240

原创 redis

一  安装redis3.0+才有集群功能。安装的前提条件:需要安装gcc:yuminstall gcc-c++1、下载redis的源码包。2、把源码包上传到linux服务器3、解压源码包 tar -zxvf redis-3.0.0.tar.gz 4、Make5、Make install[root@bogon redis-3.0.0]# make  PREFI

2017-06-10 13:53:29 186

原创 insertion-sort-list

//Sort a linked list using insertion sort//单链表的插入排序/** * Definition for singly-linked list. * public class ListNode  *{ *     int val; *     ListNode next; *     ListNode(int x) { 

2017-06-06 20:50:47 158

原创 sorl-list

/** * 单链表的排序 * 归并排序的基本思想:找到链表的中间节点,然后递归对前半部分和后半部分分别进行归并排序,最后对两个以排好序的链表进行合并 * @author cfp008 * */public class SortList {    class ListNode    {        int val;        ListNode nex

2017-05-20 16:40:18 234

原创 max-points-on-a-line

//Given n points on a 2D plane, find the maximum number of points that lie on the same straight line.class Point {    int x;    int y;    Point() { x = 0; y = 0; }    Point(int a, int b)

2017-05-17 21:58:49 219

原创 evaluate-reverse-polish-notation

Evaluate the value of an arithmetic expression inReverse Polish Notation.Valid operators are+,-,*,/. Each operand may be an integer or another expression.Some examples:["2", "1", "+", "3", "

2017-05-15 22:12:07 161

原创 Minimum Depth of Binary Tree

//Given a binary tree, find its minimum depth.The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node.//求二叉树的最小深度,与求最大深度非常类似,但需要增加左右子树的判断,

2017-05-15 21:59:10 156

原创 在虚拟机(CentOS)上配置fastdfs+nginx

废话不多说!用到的包如下:FastDFS--tracker安装01 :如果没有gcc环境,安装:yum  install  gcc-c++02:FastDFS依赖libevent库,需要安装:yum -y install libevent03:libfastcommon是FastDFS官方提供的,libfastcommon包含了FastDFS运行所需要的一些基础库。

2017-04-24 02:26:12 1103

原创 spring整合dubbo

dubbo原理,简图:服务提供方dubbo-provider.xml配置:                                服务消费方dubbo-consumer.xml配置:        注意:在zookeeper服务器上关闭防火墙,否则连不上;消费方和提供方之间传输的对象要实现serializa

2017-03-31 21:41:10 220

原创 设计模式之单例模式

1 单例模式的实现场景创建一个对象需要消耗过多的资源,如要访问IO和数据库等资源,为避免产生多个对象消耗过多资源,需要考虑使用单例模式。2  实现单例模式的几个关键点1)构造函数私有化2)通过一个静态方法或枚举返回单例类对象3)确保单例类的对象有且只有一个,特别是在多线程环境下4)确保单例类的对象在反序列化时不会重新构建对象反序列化操作提供了一个很特别的钩子函数,类中具

2017-03-12 00:55:00 212

原创 系统之间共享cookie的要求

在分布式系统中,系统之间需要共享cookie时,要求 :1 domain必须相同,如www.baidu.com,search.baidu.com,sso.baidu.com,domain必须设置为.baidu.com2 path设置为/3 域名如果是localhost,不需要设置domain,直接设置path为/

2017-02-25 00:06:55 615

原创 单机版Solr6.0+整合Tomcat与中文分词器IKAnalyzer

前提:配置好运行环境solr 需要运行在一个Servlet容器中,要求jdk使用1.7以上,Solr默认提供Jetty(java写的Servlet容器),本文使用Tocmat8作为Servlet容器,Solr版本为6.3.0。在Tomcat中部署Solr1,将solr-6.3.0\server\solr-webapp中的webapp拷贝到tomcat的webapps目录下并将webap

2017-01-02 23:53:57 599

原创 spring和springmvc父子容器关系

今天碰到一个问题,在springmvc.xml中配置后加载不了properties配置文件中的属性,而在applicationContext-*.xml中配置却可以正常加载到属性,这个问题其实就涉及到spring和springmvc父子容器的关系。父容器不能访问子容器中的对象,而子容器可以访问父容器中的对象。applicationContext-*.xml是配置在父容器中的,springmvc

2016-12-21 00:12:11 911

原创 上传图片到tomcat服务器(tomcat7-maven-plugin)

本来比较好的做法是将图片上传到图片服务器(nginx),但nginx主要用在linux平台,由于客观原因暂不考虑。然后想到的是设置tomcat服务器虚拟路径,服务器路径映射到本地磁盘路径,将图片上传到本地磁盘中。但是项目中tomcat是以插件的形式内嵌到maven中(pom文件依赖tomcat7-maven-plugin),没有找到设置虚拟路径的方法,于是退而求其次,将图片上传到tomcat服务器

2016-12-08 21:06:02 2853

原创 ssm目录结构及相关配置

废话不多说,直接上图,以下是用Maven管理的一个ssm项目目录结构,所用到的jar包:数据库驱动包、mybatis的jar包、mybatis与spring的整合包、dbcp或c3p0数据库连接池包、spring所有jar包、log4j包、jstl包。。。这里主要涉及几个主要的配置文件:sqlMapConfig.xml是mybatis的配置文件,mybatis与spring整合后不需要

2016-11-24 22:41:10 7386

转载 多线程中Condition的使用

转载地址:http://blog.csdn.net/wxwzy738/article/details/8522493JDK原话,假定有一个绑定的缓冲区,它支持 put 和 take 方法。如果试图在空的缓冲区上执行 take 操作,则在某一个项变得可用之前,线程将一直阻塞;如果试图在满的缓冲区上执行 put 操作,则在有空间变得可用之前,线程将一直阻塞。我们喜欢在单独的等待 set 中

2016-11-21 22:37:59 439

原创 java多线程02:线程通信

/* * 子线程循环10次,接着主线程循环100,这个过程循环50次 */public class ThreadCommunication {public static void main(String[] args) {Business _business = new Business();new Thread(new Runnable(){@Overri

2016-11-19 22:26:18 207

原创 java多线程01:创建线程的两种传统方式

Thread类内部有个run()方法,线程执行时就是执行这个方法,源码为:private Runnable target;    public void run() {        if (target != null) {            target.run();        }    }其中target是一个Runnable接口对象,可以看到线程

2016-11-18 19:59:35 336

转载 java synchronized详解

转载地址:http://www.cnblogs.com/GnagWang/archive/2011/02/27/1966606.htmlJava语言的关键字,当它用来修饰一个方法或者一个代码块的时候,能够保证在同一时刻最多只有一个线程执行该段代码。     一、当两个并发线程访问同一个对象object中的这个synchronized(this)同步代码块时,一个时间内只能有一个线程

2016-11-16 23:31:00 168

转载 java集合18--Iterator和Enumeration比较

转载地址:http://blog.csdn.net/wangxiaotongfan/article/details/51346289概要这一章,我们对Iterator和Enumeration进行比较学习。内容包括: 第1部分 Iterator和Enumeration区别 第2部分 Iterator和Enumeration实例

2016-11-11 19:22:59 169

转载 java集合17--TreeSet源码走读

转载地址:http://blog.csdn.net/wangxiaotongfan/article/details/51346266概要这一章,我们对TreeSet进行学习。 我们先对TreeSet有个整体认识,然后再学习它的源码,最后再通过实例来学会使用TreeSet。内容包括: 第1部分 TreeSet介绍 第2部分 Tr

2016-11-11 19:19:46 262

转载 java集合16-HashSet源码走读

转载地址:http://blog.csdn.net/wangxiaotongfan/article/details/51346225概要这一章,我们对HashSet进行学习。 我们先对HashSet有个整体认识,然后再学习它的源码,最后再通过实例来学会使用HashSet。内容包括: 第1部分 HashSet介绍 第2部分 Ha

2016-11-11 19:17:16 179

转载 java集合15--set架构

转载地址:http://blog.csdn.net/wangxiaotongfan/article/details/51346183前面,我们已经系统的对List和Map进行了学习。接下来,我们开始可以学习Set。相信经过Map的了解之后,学习Set会容易很多。毕竟,Set的实现类都是基于Map来实现的(HashSet是通过HashMap实现的,TreeSet是通过TreeMap实现的

2016-11-11 19:15:28 208

转载 java集合14--Map总结

转载地址:http://blog.csdn.net/wangxiaotongfan/article/details/51346167概要学完了Map的全部内容,我们再回头开开Map的框架图。本章内容包括: 第1部分 Map概括 第2部分 HashMap和Hashtable异同 第3部分 HashMap和Weak

2016-11-11 19:10:13 381

转载 java集合13--WeakHashMap源码详解

转载地址:http://blog.csdn.net/wangxiaotongfan/article/details/51346063概要这一章,我们对WeakHashMap进行学习。 我们先对WeakHashMap有个整体认识,然后再学习它的源码,最后再通过实例来学会使用WeakHashMap。第1部分 WeakHashMap介绍

2016-11-11 18:05:48 176

转载 java集合12--TreeMap源码详解

转载地址:http://blog.csdn.net/wangxiaotongfan/article/details/51345561概要这一章,我们对TreeMap进行学习。 我们先对TreeMap有个整体认识,然后再学习它的源码,最后再通过实例来学会使用TreeMap。内容包括: 第1部分 TreeMap介绍 第2部分 Tree

2016-11-11 17:58:49 534

转载 java集合11--HashTable源码详解

转载地址:http://blog.csdn.net/wangxiaotongfan/article/details/51345426概要前一章,我们学习了HashMap。这一章,我们对Hashtable进行学习。 我们先对Hashtable有个整体认识,然后再学习它的源码,最后再通过实例来学会使用Hashtable。第1部分 Ha

2016-11-11 17:54:55 166

转载 java集合10--HashMap源码走读

转载地址:http://blog.csdn.net/wangxiaotongfan/article/details/51335368概要这一章,我们对HashMap进行学习。 我们先对HashMap有个整体认识,然后再学习它的源码,最后再通过实例来学会使用HashMap。内容包括: 第1部分 HashMap介绍 第2部分 Ha

2016-11-11 17:50:19 429

转载 java集合09--Map架构

转载地址:http://blog.csdn.net/wangxiaotongfan/article/details/51334374概要前面,我们已经系统的对List进行了学习。接下来,我们先学习Map,然后再学习Set;因为Set的实现类都是基于Map来实现的(如,HashSet是通过HashMap实现的,TreeSet是通过TreeMap

2016-11-11 17:47:57 152

转载 java集合08--List总结

转载地址:http://blog.csdn.net/wangxiaotongfan/article/details/51332950概要前面,我们学完了List的全部内容,详细内容请看前面的几篇博客,现在,我们再回头看看总结一下List。内容包括:第1部分 List概括第2部分 List使用场景第3部分 LinkedList和ArrayList性能差异分

2016-11-11 17:44:16 318

转载 java集合07--Stack源码解读

转载地址:http://blog.csdn.net/wangxiaotongfan/article/details/51332623概要学完Vector了之后,接下来我们开始学习Stack。Stack很简单,它继承于Vector。学习方式还是和之前一样,先对Stack有个整体认识,然后再学习它的源码;最后再通过实例来学会使用它。内容包括:第1部分 Stack介绍第2

2016-11-11 17:40:19 207

转载 Java集合06--Vector源码详解

转载地址:http://blog.csdn.net/wangxiaotongfan/article/details/51332193概要学完ArrayList和LinkedList之后,我们接着学习Vector。学习方式还是和之前一样,先对Vector有个整体认识,然后再学习它的源码;最后再通过实例来学会使用它。第1部分 Vector介绍第2部分 Vecto

2016-11-11 17:35:28 501

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除