- 博客(14)
- 收藏
- 关注
原创 Golang 设计模式系列5: 桥接模式(Bridge Pattern)
桥接模式(Bridge Pattern):将抽象部分与它的实现部分分离,使它们都可以独立地变化。它是一种对象结构型模式,又称为柄体(Handle and Body)模式或接口(Interface)模式。在桥接模式结构图中包含如下几个角色:Abstraction(抽象类):用于定义抽象类的接口,它一般是抽象类而不是接口,其中定义了一个 Implementor(实现类接口)类型的对象并可以维...
2019-10-19 16:21:51
387
原创 Golang 设计模式系列4: 适配器模式(Adapter design pattern)
适配器模式(Adapter Pattern) :将一个接口转换成客户希望的另一个接口,适配器模式使接口不兼容的那些类可以一起工作,其别名为包装器(Wrapper)。适配器模式既可以作为类结构型模式,也可以作为对象结构型模式。适配器模式包含如下角色:Target:目标抽象类Adapter:适配器类Adaptee:适配者类Client:客户类实现Target:目标抽象类type L...
2019-10-17 20:46:30
289
原创 Golang 设计模式系列3: 组合模式(Composite design pattern)
组合结构包含一下对象:Base Component(基础组件) - 基础组件是组合中所有对象的接口,客户端程序使用基础组件来处理组合中的对象。 它可以是一个接口或一个抽象类,包含一些对所有对象都是通用的方法。Leaf(叶子对象) - 定义组合中元素的行为。 它是组合的基本组成部分,并且实现了基础组件。 它没有对其他组件的引用。Composite(组合对象) – 它由叶元素组成并实现基本组件...
2019-10-16 21:56:17
285
原创 Golang 设计模式系列1:单例模式 (Singleton Design Pattern)
单例模式(Singleton Design Pattern)单例模式顾名思义,会提供给用户一个对象(object)的实例(instance) ,并且保证这个实例全局唯一。单列模式的应用场景很多,比如:当你想用同一个链接来访问数据库的时候当你用一个ssh 链接服务器并执行一些命令,但你不想每次都重开ssh的时候当你想要限制访问某些资源的时候目标我们考虑在需要应用以下规则时使用Sin...
2019-10-16 18:51:43
244
原创 SSL Cetificate 生成
首先,理解一下证书的类型。 SSL证书包括: 1,CA证书,也叫根证书或者中间级证书。如果是单向https认证的话,该证书是可选的。不安装CA证书的话,浏览器默认是不安全的。 2,服务器证书,必选项。通过key,证书请求文件csr,再通过CA证书签名,生成服务器证书。 3,客户端证书,可选项。若有客户端证书则是双向https验证。 以上所有证书都可以自己生成。 ...
2018-04-23 14:43:36
233
原创 514. Freedom Trail
514. Freedom TrailIn the video game Fallout 4, the quest “Road to Freedom” requires players to reach a metal dial called the “Freedom Trail Ring”, and use the dial to spell a specific keyword in order
2017-07-14 23:20:47
210
原创 552. Student Attendance Record II
552. Student Attendance Record IIGiven a positive integer n, return the number of all possible attendance records with length n, which will be regarded as rewardable. The answer may be very large, retu
2017-07-14 17:20:16
285
原创 564. Find the Closest Palindrome
564. Find the Closest PalindromeGiven an integer n, find the closest integer (not including itself), which is a palindrome.The ‘closest’ is defined as absolute difference minimized between two integers
2017-07-14 17:09:25
414
原创 600. Non-negative Integers without Consecutive Ones
600. Non-negative Integers without Consecutive OnesGiven a positive integer n, find the number of non-negative integers less than or equal to n, whose binary representations do NOT contain consecutive
2017-07-14 00:34:24
231
原创 629. K Inverse Pairs Array
629. K Inverse Pairs ArrayGiven two integers n and k, find how many different arrays consist of numbers from 1 to n such that there are exactly k inverse pairs.We define an inverse pair as following: F
2017-07-14 00:15:49
179
原创 632. Smallest Range
632. Smallest RangeYou have k lists of sorted integers in ascending order. Find the smallest range that includes at least one number from each of the k lists.We define the range [a,b] is smaller than r
2017-07-13 23:47:14
306
原创 Single Number 系列
Single Number 系列Single NumberGiven an array of integers, every element appears twice except for one. Find that single one.Note: Your algorithm should have a linear runtime complexity. Could you imple
2017-07-07 15:51:18
253
原创 python Setuptools
what is setuptoolsSetuptools is a fully-featured, actively-maintained, and stable library designed to facilitate packaging Python projects, where packaging includes:Python package and module defi
2016-10-17 11:53:27
315
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人