- 博客(70)
- 资源 (9)
- 收藏
- 关注
原创 std::thread 的并发测试
std::thread 的并发测试,测试两方面的性能:1 并发同步锁的最优位置2 并发最优线程数量直接上代码:void Ticket::Sell(const int tickets){ this->tickes = tickets; clock_t start, end; start = clock(); vector<std::thread> threadLst; for (int i = 0; i < 36; ++i) { threadLs
2021-01-12 11:41:06 291
原创 QMap 之 swap 特性
QMap<int, int> mp1; mp1.insert(1,2); mp1.insert(2,3); QMap<int, int> mp2; mp2.swap(mp1); qDebug()<<mp1.size(); mp2.clear(); qDebug()<<mp1.si...
2019-08-30 09:53:04 2112 1
原创 Android抽奖实现
第一章:实现简易抽奖1.1 实现步骤1.2 程序示例第一步:TextView lotteryNumberTv = findViewById(R.id.lotteryView);第二步:Random random = new Random();第三步:int n = random.nextInt(100);第四步: lotteryNumberT...
2018-10-17 16:57:27 1133
原创 Android 实践一 hello world
activity_main.xml :<?xml version="1.0" encoding="utf-8"?><android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="ht...
2018-08-21 12:15:10 191
原创 初识Android第一坑,预览不可见
<resources> <!-- Base application theme. --> <style name="AppTheme" parent="Base.Theme.AppCompat.Light.DarkActionBar"> <!-- Customize your theme here. --> ...
2018-08-20 18:18:45 246
原创 vs 汇编输出到控制台
代码写到一定量,了解下汇编先.386.model flat, stdcalloption casemap :noneincludelib kernel32.libincludelib masm32.libExitProcess PROTO STDCALL:DWORDStdOut PROTO STDCALL:DWORD.dataHelloWorld db "Hello...
2018-08-07 20:55:33 1441
原创 KMeans算法实现
闲得,自己琢磨了KMeans算法,记录下。原理网络一大把,不再累述# -*- coding: utf-8 -*-"""Created on Wed May 16 23:02:51 2018@author: mz"""import mathimport randomfrom sklearn import datasetsimport numpy as npimport copy...
2018-05-31 23:55:08 371
原创 Python 解析器模式
# -*- coding: utf-8 -*-"""Created on Thu Mar 29 19:26:13 2018@author: mz"""class Context(object): def SetContect(self, rhs): self.context = rhs def GetContext(self): ret...
2018-03-29 19:58:14 398
原创 Python 访问者模式
# -*- coding: utf-8 -*-"""Created on Thu Mar 29 16:52:56 2018@author: mz"""class Aggregate(object): def __init__(self): self._elmlst = [] def Attach(self, elm): sel...
2018-03-29 19:25:27 214
原创 Python 迭代模式
# -*- coding: utf-8 -*-"""Created on Thu Mar 29 11:43:05 2018@author: mz"""class Iterator(object): def Next(self): pass def HasNext(self): pass def First(self): ...
2018-03-29 15:28:31 401
原创 Python 建造者模式
# -*- coding: utf-8 -*-"""Created on Thu Mar 29 10:19:38 2018@author: mz"""class Director(object): def Build(self, builder): builder.BuildFloor() builder.BuildWindow...
2018-03-29 11:00:20 329
原创 Python 享元模式
# -*- coding: utf-8 -*-"""Created on Wed Mar 28 20:41:17 2018@author: mz"""class Share(object): def __init__(self): self.d = {} def Attach(self, key, value): if key...
2018-03-28 20:55:32 179
原创 Python 原型模式
# -*- coding: utf-8 -*-"""Created on Wed Mar 28 19:41:57 2018@author: mz"""from copy import copy, deepcopyclass Prototype(object): def Clone(self): pass def DeepClone(sel...
2018-03-28 20:33:21 225
原创 Python 观察者模式
# -*- coding: utf-8 -*-"""Created on Wed Mar 28 18:50:47 2018@author: mz"""#observerclass Boss(object): def __init__(self): self.obj = []; def Attach(self, employee): ...
2018-03-28 19:40:11 175
原创 Python 模板方法
# -*- coding: utf-8 -*-"""Created on Tue Mar 27 17:08:14 2018@author: mz"""class Template(object): def Excute(self): self.ReadyRead() self.ReadyWrite() def Read...
2018-03-27 17:14:49 302
原创 Python 外观模式
# -*- coding: utf-8 -*-"""Created on Tue Mar 27 16:56:43 2018@author: mz"""class Facade(object): def TradeWar(self): a = ASubject() b = BSubject() c = CSubject() ...
2018-03-27 17:06:48 223
原创 Python 单例模式
# -*- coding: utf-8 -*-"""Created on Mon Mar 26 19:40:24 2018@author: mz"""import threadingclass Singleton(object): _instance_lock = threading.Lock() def __init__(self): pass...
2018-03-27 11:54:44 976
原创 Python 代理模式
# -*- coding: utf-8 -*-"""Created on Mon Mar 26 19:17:20 2018@author: mz"""class Person(object): def ShowLove(self): passclass Girl(Person): def ShowLove(self): pass...
2018-03-26 19:34:49 141
原创 Python 命令模式
# -*- coding: utf-8 -*-"""Created on Mon Mar 26 17:17:02 2018@author: mz"""class ICommand(object): def __init__(self, rhs): self.rcv = rhs def Excute(self): passc...
2018-03-26 18:51:23 343
原创 Python 备忘录模式
Created on Sun Mar 18 00:30:51 2018@author: mz"""class Original(object): def save(self, state): print("save status: %s" %(state)) self.__status = state def get(se...
2018-03-18 00:49:07 273
原创 Python 适配器模式
# -*- coding: utf-8 -*-"""Created on Sun Mar 18 00:08:14 2018@author: mz"""class Target(object): def charge(self, adaptor): print("110V charge on 220V->") adaptor...
2018-03-18 00:14:35 263
原创 Python 抽象工厂
# -*- coding: utf-8 -*-"""Created on Sat Mar 3 21:56:58 2018@author: mz"""class IFactory(object): def ProduceB(self): pass def ProduceA(self): pass class...
2018-03-18 00:07:24 234
原创 Python 桥接模式
# -*- coding: utf-8 -*-"""Created on Thu Mar 15 12:01:02 2018@author: mz"""class Phone(object): def setGame(self, rhs): self.game = rhs class IOSPhone(Phone): def playGa...
2018-03-18 00:05:57 161
原创 Python 中介模式
# -*- coding: utf-8 -*-"""Created on Thu Mar 15 15:26:07 2018@author: mz"""class Mediator(object): def declare(self, msg, owner): self.__receiver.receive(msg) def ...
2018-03-18 00:04:16 300
原创 Python 之工厂方法
# -*- coding: utf-8 -*-"""Created on Sat Mar 3 21:42:27 2018@author: mz"""class IFactory(object): def Product(self): pass class IMethod(object): def DoAsIMean(self): ...
2018-03-03 21:55:14 1360
原创 QT 一信号对应多个槽函数
网络上搜索,大部分都废话连篇,直接上码测试此功能,结果显示OK。分别创建三个类,A,B,C。信号和槽绑定关系如下,一个信号绑定两个槽函数:A::A(QObject *parent) : QObject(parent){ B* b = new B(); C* c = new C(); connect(this, SIGNAL(Greet()), b, SLOT(Respo...
2018-02-26 23:48:58 13172 1
原创 Python 状态模式
# -*- coding: utf-8 -*-"""Created on Mon Feb 26 20:45:13 2018@author: mz"""class Status(object): def Handle(self, rhs): pass class AStatus(Status): def Handle(self, rhs): ...
2018-02-26 21:38:55 160
原创 Python 责任链模式实现
# -*- coding: utf-8 -*-"""Created on Mon Feb 26 11:45:46 2018@author: mz"""class Handler(object): def __init__(self): self.handler = None def Handle(self): pass ...
2018-02-26 14:15:52 242
原创 Python 装饰器模式
# -*- coding: utf-8 -*-"""Created on Sat Feb 24 11:37:17 2018@author: mz"""class Warrior: def __init__(self): self.attrack = 100 self.defend = 200 de...
2018-02-24 16:37:40 245
原创 Python 组合模式
# -*- coding: utf-8 -*-"""Created on Mon Feb 12 16:30:45 2018@author: mz"""class Component(object): def __init__(self, name): self.name = name self.child = [] ...
2018-02-12 17:28:52 296
原创 Python 策略模式
简单的用策略模式熟悉Python编程# -*- coding: utf-8 -*-"""Created on Mon Feb 12 15:48:29 2018@author: mz"""class Strategy(object): def action(self): pass class ConcreteStrategyA(Strategy...
2018-02-12 17:01:49 157
原创 外观模式C++实现
外观模式用于接口对接处理,为执行一个功能,需要不同的子系统分别执行对应功能。 外观类: #include "StdAfx.h"#include "Facade.h"#include "SubSystemA.h"#include "SubSystemB.h"#include "SubSystemC.h"#include "SubSystemD.
2018-02-12 09:14:55 139
原创 访问者模式C++实现
解释器模式,可理解的场景有,五线谱解读为哆啦咪发唆西多,翻译,名词解释等。可交叉解析,也可用一种解析器解析。待解析内容: #pragma once#include <iostream>using namespace std;class InterContext{public: InterContext(void); ~InterContext(void); Inte...
2018-02-11 15:05:38 231
原创 访问者C++实现
访问者用于数据结构稳定,访问者变化的情况。如游客访问景区,游客为变动的状态,各个景点是固定的数据结构。景点结构聚类Structure:Structure.h #pragma once#include "Element.h"using namespace std;#include <vector>class Structure{public: Structure(void); ...
2018-02-11 15:03:48 128
原创 迭代模式C++实现
迭代器用于遍历聚类,而不通过直接访问聚类方式获取聚类中的信息。聚类接口Aggregate.h: #pragma once#include "IIterator.h"class Aggregate{public: Aggregate(void); virtual ~Aggregate(void); virtual IIterator* CreateIterator(void) = ...
2018-02-11 15:01:45 2453
原创 建造者模式C++实现
建造者模式用于实现复杂的构建过程。由方法论+ 具体实施者产生最终产品。 比如导演导演电影,导演电影有一套方法论。然后由各不同的演员演绎,各演员能演绎出不同的风格,最终产出一部电影。导演类: #include "StdAfx.h"#include "Director.h"Director::Director(void){}Director::~Director(void){}void Direct...
2018-02-11 14:59:51 133
原创 享元模式C++实现
享元模式主要用于节约内存开销。可看成工厂+单例模式的结合。享元类: #pragma onceclass Share{public: Share(void); virtual ~Share(void); virtual void Operation(void) = 0;}; 具体共享类: #include "StdAfx.h"#include "ConcreteShare...
2018-02-11 14:57:48 330
原创 原型模式C++实现
原型模式就是对本身进行克隆。克隆完成后,各自独立,互不影响。 原型类: #include "StdAfx.h"#include "Prototype.h"Prototype::Prototype(void) : m_age(0){}Prototype::~Prototype(void){}Prototype* Prototype::C...
2018-02-11 14:54:42 126
原创 模板方法C++实现
模板方法提供了固定方式的实现模板,内部真实实现进行封装,提供统一的外部接口给外部调用。外部不需要知道其真实实现方式。 模板方法就是方法论,方法论类: #pragma onceclass AbstractClass{public: AbstractClass(void); virtual ~AbstractClass(void); virtual void Operation1(v...
2018-02-11 14:46:50 856
原创 观察者模式C++实现
观察者模式用于当一方发生变化,触发多个同类型的事物同事发生变化的情况。如领导进出入办公室,各同事的不同反应。股市上涨,不同年龄、性别的操作者的买卖习惯等。 观察者类: #pragma onceusing namespace std;#include <vector>#include "MyObject.h"class Ob...
2018-02-11 14:41:56 177
protobuf3.15.0 用mingw810-64 版本
2024-08-27
opencv_3rdparty-ippicv-master_20191018.zip
2020-05-08
VC++和Matlab混编源码
2012-11-03
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人