摘要: 1.什么是进程? 进程是操作系统提供的抽象之一。有了进程的概念之后,CPU才有了并发或者伪并发的可能性。通俗的说来,当你的写的程序运行起来后,那么它就是一个进程了。 2.进程,伪并发,并发 首先说说并发,并发指的是在某一个时刻某些事件同时发生。 假设你的电脑只有一个CPU(这里一个指单核),然而你却 阅读全文
posted @ 2019-05-05 19:58 SkyMelody 阅读(98) 评论(0) 推荐(0) 编辑
摘要: 考虑要设计一个Messager模块,这个模块要实现如下功能 登录 发送消息 播放声音(登录或者播放的时候播放声音) 画图(登录的时候显示的图片) 那么最直观的设计如下 然后呢,我们这个Messager要实现跨平台的功能,要在PC平台和手机平台都能适用。然而对于PC和Mobile来说,唯一有区别的地方 阅读全文
posted @ 2019-05-04 00:06 SkyMelody 阅读(324) 评论(1) 推荐(0) 编辑
摘要: 考虑程序要对一类 流 (网络流,IO流等等)进行操作。进行什么操作呢?可能在读(Read)这个流的时候对这个流进行加密,也可能对这个流进行缓存。 那么很自然的能设计出以下这些类 那么这样做的缺点有什么呢?试想一下,如果我现在要对流增加新的操作,比如说要将流输出。你可能会有如下设计 哇靠,有没有搞错! 阅读全文
posted @ 2019-05-01 13:31 SkyMelody 阅读(199) 评论(0) 推荐(0) 编辑
摘要: 曾经第一次学习设计模式的时候,总觉得这玩意没有用。这段时间重新看视频学习,才领略到设计模式的好处。今天我想说说模板方法模式。 模板想必大家在生活中是经常用的。比如说写简历可以套一个简历模板,写一个网页可以套一个前端模板。当你使用一个模板的时候,你会根据自己的需求去修改模板的一部分内容。对于模板方法的 阅读全文
posted @ 2019-04-29 13:05 SkyMelody 阅读(239) 评论(0) 推荐(0) 编辑
摘要: 熟悉c++的朋友应该都知道,c++提供给了程序员与硬件打交道的可能性,比如说内存管理。一个高水平的c++程序员可以将c++程序的性能优化到极致,榨干硬件资源。而现在我想说说与内存管理有关的new 和 malloc()。 先说说malloc(),malloc是从C语言那里继承过来的一个函数,其用于分配 阅读全文
posted @ 2019-04-27 11:51 SkyMelody 阅读(1343) 评论(0) 推荐(1) 编辑
摘要: Initially on a notepad only one character 'A' is present. You can perform two operations on this notepad for each step: Copy All: You can copy all the 阅读全文
posted @ 2018-01-26 13:01 SkyMelody 阅读(99) 评论(0) 推荐(0) 编辑
摘要: A sequence of numbers is called a wiggle sequence if the differences between successive numbers strictly alternate between positive and negative. The 阅读全文
posted @ 2018-01-24 15:51 SkyMelody 阅读(100) 评论(0) 推荐(0) 编辑
摘要: You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping yo 阅读全文
posted @ 2018-01-23 20:49 SkyMelody 阅读(85) 评论(0) 推荐(0) 编辑
摘要: Say you have an array for which the ith element is the price of a given stock on day i. If you were only permitted to complete at most one transaction 阅读全文
posted @ 2017-12-24 08:33 SkyMelody 阅读(100) 评论(0) 推荐(0) 编辑
摘要: Given an array of n integers where n > 1, nums, return an array output such that output[i] is equal to the product of all the elements of nums except  阅读全文
posted @ 2017-11-28 17:48 SkyMelody 阅读(78) 评论(0) 推荐(0) 编辑