摘要: 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 阅读全文
posted @ 2017-01-12 18:21 鸭子船长 阅读(162) 评论(0) 推荐(0)
摘要: 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 p 阅读全文
posted @ 2017-01-12 17:00 鸭子船长 阅读(283) 评论(0) 推荐(0)
摘要: String.Trim()方法到底为我们做了什么,仅仅是去除字符串两端的空格吗? 一直以为Trim()方法就是把字符串两端的空格字符给删去,其实我错了,而且错的比较离谱。 首先我直接反编译String类,找到Trim()方法: 1 public string Trim() 2 { 3 return 阅读全文
posted @ 2017-01-12 15:46 鸭子船长 阅读(33513) 评论(1) 推荐(4)
摘要: 定义:动态给一个对象添加一些额外的职责,就象在墙上刷油漆.使用Decorator模式相比用生成子类方式达到功能的扩充显得更为灵活。设计初衷:通常可以使用继承来实现功能的拓展,如果这些需要拓展的功能的种类很繁多,那么势必生成很多子类,增加系统的复杂性,同时,使用继承实现功能拓展,我们必须可预见这些拓展 阅读全文
posted @ 2017-01-12 14:43 鸭子船长 阅读(183) 评论(0) 推荐(0)
摘要: 工厂模式在《Java与模式》中分为三类:1)简单工厂模式(Simple Factory):不利于产生系列产品;2)工厂方法模式(Factory Method):又称为多形性工厂;3)抽象工厂模式(Abstract Factory):又称为工具箱,产生产品族,但不利于产生新的产品; 这三种模式从上到下 阅读全文
posted @ 2017-01-12 09:40 鸭子船长 阅读(967) 评论(0) 推荐(0)