Skip to content

Commit 74ca039

Browse files
committed
update(2021-04-08 17:40)
1 parent 76451ea commit 74ca039

File tree

69 files changed

+76
-72
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+76
-72
lines changed

_posts/swift-design-patterns/2020-05-01-swift-design-patterns.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ categories: [代码人生, 设计模式]
66
pin: true
77
---
88

9+
数据结构与算法教你写出高效的代码,设计模式教你写出高质量的代码
10+
11+
<!-- more -->
12+
913
## 创建型模式
1014

1115
- **[工厂方法模式](/posts/swift-design-patterns-factory-method/)**:在父类中提供一个创建对象的方法,允许子类决定实例化对象的类型。

_site/404.html

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

_site/about/index.html

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

_site/archives/index.html

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

_site/assets/js/data/search.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

_site/categories/flutter/index.html

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

_site/categories/git/index.html

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

_site/categories/index.html

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

_site/categories/ios/index.html

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

_site/categories/leetcode/index.html

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

_site/categories/代码人生/index.html

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

_site/categories/小程序/index.html

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

_site/categories/设计模式/index.html

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

_site/feed.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<feed xmlns="http://www.w3.org/2005/Atom"> <id>https://kokohuang.github.io/</id><title>kokohuang's blog</title><subtitle>kokohuang's blog.</subtitle> <updated>2021-04-08T17:37:17+08:00</updated> <author> <name>kokohuang</name> <uri>https://kokohuang.github.io/</uri> </author><link rel="self" type="application/atom+xml" href="https://kokohuang.github.io/feed.xml"/><link rel="alternate" type="text/html" hreflang="zh-CN" href="https://kokohuang.github.io/"/> <generator uri="https://jekyllrb.com/" version="4.2.0">Jekyll</generator> <rights> © 2021 kokohuang </rights> <icon>/assets/img/favicons/favicon.ico</icon> <logo>/assets/img/favicons/favicon-96x96.png</logo> <entry><title>LeetCode 刷题笔记</title><link href="https://kokohuang.github.io/posts/swift-leetcode/" rel="alternate" type="text/html" title="LeetCode 刷题笔记" /><published>2021-04-08T12:00:00+08:00</published> <updated>2021-04-08T17:35:38+08:00</updated> <id>https://kokohuang.github.io/posts/swift-leetcode/</id> <content src="https://kokohuang.github.io/posts/swift-leetcode/" /> <author> <name>kokohuang</name> </author> <category term="代码人生" /> <category term="LeetCode" /> <summary> LeetCode 刷题笔记,持续更新ing… 序号 标题 难度 时间复杂度 空间复杂度 题解 1 两数之和 简单 O(n) O(n) Swift 26 删除有序数组中的重复项 简单 O(n) O(1) Swift </summary> </entry> <entry><title>LeetCode - 删除有序数组中的重复项</title><link href="https://kokohuang.github.io/posts/swift-leetcode-0026/" rel="alternate" type="text/html" title="LeetCode - 删除有序数组中的重复项" /><published>2021-04-08T12:00:00+08:00</published> <updated>2021-04-08T17:23:21+08:00</updated> <id>https://kokohuang.github.io/posts/swift-leetcode-0026/</id> <content src="https://kokohuang.github.io/posts/swift-leetcode-0026/" /> <author> <name>kokohuang</name> </author> <category term="代码人生" /> <category term="LeetCode" /> <summary> 题目链接:删除有序数组中的重复项 主要思路 定义一个索引index, 遍历数组过程中与该索引的值进行对比,如果不一致,则修改对应索引的值 代码实现 /** * 时间复杂度: O(n), 空间复杂度: O(1) */ class Solution { func removeDuplicates(_ nums: inout [Int]) -&amp;gt; Int { guard nums.count &amp;gt; 0 else { return 0 } var index = 0 for num in nums where num != nums[index] { index += 1 nums[index] = num } ... </summary> </entry> <entry><title>LeetCode - 两数之和</title><link href="https://kokohuang.github.io/posts/swift-leetcode-0001/" rel="alternate" type="text/html" title="LeetCode - 两数之和" /><published>2021-04-08T12:00:00+08:00</published> <updated>2021-04-08T12:00:00+08:00</updated> <id>https://kokohuang.github.io/posts/swift-leetcode-0001/</id> <content src="https://kokohuang.github.io/posts/swift-leetcode-0001/" /> <author> <name>kokohuang</name> </author> <category term="代码人生" /> <category term="LeetCode" /> <summary> 题目链接:两数之和 主要思路 遍历数组,并且使用 map 存储 target - nums[i] 的值 代码实现 /** * 时间复杂度: O(n), 空间复杂度: O(n) */ class Solution { func twoSum(_ nums: [Int], _ target: Int) -&amp;gt; [Int] { var dict = [Int: Int]() for (i, num) in nums.enumerated() { if let lastIndex = dict[target - num] { return [lastIndex, i] } dict[num] = i } ... </summary> </entry> <entry><title>Swift设计模式概览</title><link href="https://kokohuang.github.io/posts/swift-design-patterns/" rel="alternate" type="text/html" title="Swift设计模式概览" /><published>2020-05-01T12:00:00+08:00</published> <updated>2020-05-01T12:00:00+08:00</updated> <id>https://kokohuang.github.io/posts/swift-design-patterns/</id> <content src="https://kokohuang.github.io/posts/swift-design-patterns/" /> <author> <name>kokohuang</name> </author> <category term="代码人生" /> <category term="设计模式" /> <summary> 创建型模式 工厂方法模式:在父类中提供一个创建对象的方法,允许子类决定实例化对象的类型。 抽象工厂模式:让你能创建一系列相关的对象,而无需指定其具体类。 生成器模式:使你能够分步骤创建复杂对象。该模式允许你使用相同的创建代码生成不同类型和形式的对象。 原型模式:使你能够复制已有对象,而又无需使代码依赖它们所属的类。 单例模式:让你能够保证一个类只有一个实例,并提供一个访问该实例的全局节点。 结构型模式 适配器模式:使接口不兼容的对象能够相互合作。 桥接模式:可将一个大类或一系列紧密相关的类拆分为抽象和实现两个独立的层次结构,从而能在开发时分别使用。 组合模式:可以使用它将对象组合成树状结构,并且能像使用独立对象一样使用它... </summary> </entry> <entry><title>Swift设计模式之「模板方法模式」</title><link href="https://kokohuang.github.io/posts/swift-design-patterns-template-method/" rel="alternate" type="text/html" title="Swift设计模式之「模板方法模式」" /><published>2020-04-22T12:00:00+08:00</published> <updated>2020-04-22T12:00:00+08:00</updated> <id>https://kokohuang.github.io/posts/swift-design-patterns-template-method/</id> <content src="https://kokohuang.github.io/posts/swift-design-patterns-template-method/" /> <author> <name>kokohuang</name> </author> <category term="代码人生" /> <category term="设计模式" /> <summary> 在父类中提供一个创建对象的方法,允许子类决定实例化对象的类型。 </summary> </entry> </feed>
1+
<feed xmlns="http://www.w3.org/2005/Atom"> <id>https://kokohuang.github.io/</id><title>kokohuang's blog</title><subtitle>kokohuang's blog.</subtitle> <updated>2021-04-08T17:40:10+08:00</updated> <author> <name>kokohuang</name> <uri>https://kokohuang.github.io/</uri> </author><link rel="self" type="application/atom+xml" href="https://kokohuang.github.io/feed.xml"/><link rel="alternate" type="text/html" hreflang="zh-CN" href="https://kokohuang.github.io/"/> <generator uri="https://jekyllrb.com/" version="4.2.0">Jekyll</generator> <rights> © 2021 kokohuang </rights> <icon>/assets/img/favicons/favicon.ico</icon> <logo>/assets/img/favicons/favicon-96x96.png</logo> <entry><title>LeetCode 刷题笔记</title><link href="https://kokohuang.github.io/posts/swift-leetcode/" rel="alternate" type="text/html" title="LeetCode 刷题笔记" /><published>2021-04-08T12:00:00+08:00</published> <updated>2021-04-08T17:35:38+08:00</updated> <id>https://kokohuang.github.io/posts/swift-leetcode/</id> <content src="https://kokohuang.github.io/posts/swift-leetcode/" /> <author> <name>kokohuang</name> </author> <category term="代码人生" /> <category term="LeetCode" /> <summary> LeetCode 刷题笔记,持续更新ing… 序号 标题 难度 时间复杂度 空间复杂度 题解 1 两数之和 简单 O(n) O(n) Swift 26 删除有序数组中的重复项 简单 O(n) O(1) Swift </summary> </entry> <entry><title>LeetCode - 删除有序数组中的重复项</title><link href="https://kokohuang.github.io/posts/swift-leetcode-0026/" rel="alternate" type="text/html" title="LeetCode - 删除有序数组中的重复项" /><published>2021-04-08T12:00:00+08:00</published> <updated>2021-04-08T17:23:21+08:00</updated> <id>https://kokohuang.github.io/posts/swift-leetcode-0026/</id> <content src="https://kokohuang.github.io/posts/swift-leetcode-0026/" /> <author> <name>kokohuang</name> </author> <category term="代码人生" /> <category term="LeetCode" /> <summary> 题目链接:删除有序数组中的重复项 主要思路 定义一个索引index, 遍历数组过程中与该索引的值进行对比,如果不一致,则修改对应索引的值 代码实现 /** * 时间复杂度: O(n), 空间复杂度: O(1) */ class Solution { func removeDuplicates(_ nums: inout [Int]) -&amp;gt; Int { guard nums.count &amp;gt; 0 else { return 0 } var index = 0 for num in nums where num != nums[index] { index += 1 nums[index] = num } ... </summary> </entry> <entry><title>LeetCode - 两数之和</title><link href="https://kokohuang.github.io/posts/swift-leetcode-0001/" rel="alternate" type="text/html" title="LeetCode - 两数之和" /><published>2021-04-08T12:00:00+08:00</published> <updated>2021-04-08T12:00:00+08:00</updated> <id>https://kokohuang.github.io/posts/swift-leetcode-0001/</id> <content src="https://kokohuang.github.io/posts/swift-leetcode-0001/" /> <author> <name>kokohuang</name> </author> <category term="代码人生" /> <category term="LeetCode" /> <summary> 题目链接:两数之和 主要思路 遍历数组,并且使用 map 存储 target - nums[i] 的值 代码实现 /** * 时间复杂度: O(n), 空间复杂度: O(n) */ class Solution { func twoSum(_ nums: [Int], _ target: Int) -&amp;gt; [Int] { var dict = [Int: Int]() for (i, num) in nums.enumerated() { if let lastIndex = dict[target - num] { return [lastIndex, i] } dict[num] = i } ... </summary> </entry> <entry><title>Swift设计模式概览</title><link href="https://kokohuang.github.io/posts/swift-design-patterns/" rel="alternate" type="text/html" title="Swift设计模式概览" /><published>2020-05-01T12:00:00+08:00</published> <updated>2021-04-08T17:37:20+08:00</updated> <id>https://kokohuang.github.io/posts/swift-design-patterns/</id> <content src="https://kokohuang.github.io/posts/swift-design-patterns/" /> <author> <name>kokohuang</name> </author> <category term="代码人生" /> <category term="设计模式" /> <summary> 数据结构与算法教你写出高效的代码,设计模式教你写出高质量的代码 创建型模式 工厂方法模式:在父类中提供一个创建对象的方法,允许子类决定实例化对象的类型。 抽象工厂模式:让你能创建一系列相关的对象,而无需指定其具体类。 生成器模式:使你能够分步骤创建复杂对象。该模式允许你使用相同的创建代码生成不同类型和形式的对象。 原型模式:使你能够复制已有对象,而又无需使代码依赖它们所属的类。 单例模式:让你能够保证一个类只有一个实例,并提供一个访问该实例的全局节点。 结构型模式 适配器模式:使接口不兼容的对象能够相互合作。 桥接模式:可将一个大类或一系列紧密相关的类拆分为抽象和实现两个独立的层次结构,从而能在开发时分别使用。 组... </summary> </entry> <entry><title>Swift设计模式之「模板方法模式」</title><link href="https://kokohuang.github.io/posts/swift-design-patterns-template-method/" rel="alternate" type="text/html" title="Swift设计模式之「模板方法模式」" /><published>2020-04-22T12:00:00+08:00</published> <updated>2020-04-22T12:00:00+08:00</updated> <id>https://kokohuang.github.io/posts/swift-design-patterns-template-method/</id> <content src="https://kokohuang.github.io/posts/swift-design-patterns-template-method/" /> <author> <name>kokohuang</name> </author> <category term="代码人生" /> <category term="设计模式" /> <summary> 在父类中提供一个创建对象的方法,允许子类决定实例化对象的类型。 </summary> </entry> </feed>

_site/index.html

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

_site/page2/index.html

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

_site/page3/index.html

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

_site/page4/index.html

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)