2023年2月20日
摘要:
1 int n; 2 int a[1005],c[1005]; //对应原数组和树状数组 3 4 int lowbit(int x){ 5 return x&(-x); 6 } 7 8 void updata(int i,int k){ //在i位置加上k 9 while(i <= n){ 10 c
阅读全文
posted @ 2023-02-20 20:58
么么打123
阅读(20)
推荐(0)
摘要:
1 struct node 2 { 3 int l,r,sum,lazy; 4 node *lson,*rson; 5 node() 6 { 7 l = r = sum = lazy = 0; 8 lson = rson = NULL; 9 } 10 }; 11 12 node* build(vec
阅读全文
posted @ 2023-02-20 15:06
么么打123
阅读(21)
推荐(0)
2022年11月14日
摘要:
多进程-进程池 1 from concurrent.futures import ProcessPoolExecutor 2 3 with ProcessPoolExecutor(max_workers=10) as executor: 4 results = executor.map(func,
阅读全文
posted @ 2022-11-14 19:39
么么打123
阅读(93)
推荐(0)
2019年5月3日
摘要:
作用:当我们需要在不指定类名的情况下生成实例时,可以使用Prototype模式来通过复制生成实例 UML类图: Product接口: Manager类:生成对应的克隆对象 MessageBox类:克隆对象生成的主体实现 UnderlinePen类:克隆对象生成的主体实现 main函数: 模式细谈:P
阅读全文
posted @ 2019-05-03 21:13
么么打123
阅读(194)
推荐(0)
摘要:
作用:只生成一个实例 要点:类自身的构造函数为private(防止自己生成实例) 生成实例只有一种方法,包括了构造函数的getInstance,该函数为static,所以在没有对象时可以通过类名直接调用
阅读全文
posted @ 2019-05-03 17:18
么么打123
阅读(90)
推荐(0)
2019年4月29日
摘要:
作用:将实例的生成交给子类 用Template Method模式来构建生成实例的工厂,这就是Factory Method模式。 在Factory Method中,父类决定实例的生成方式,但并不决定所要生成的具体的类,具体的处理全部交给子类去负责 UML类图: Product类: use方法的实现交给
阅读全文
posted @ 2019-04-29 19:54
么么打123
阅读(138)
推荐(0)
摘要:
作用:将具体的处理交给子类 什么是Template Method模式? Template Method模式是指带有模板功能的模式,组成模板的方法被定义在父类中,且这些方法为抽象方法。子类去实现父类中的抽象方法,即在子类种再进行对应的方法实现。 所以在父类中定义所需的框架,子类中去实现对应的方法,这就
阅读全文
posted @ 2019-04-29 17:40
么么打123
阅读(104)
推荐(0)
2019年4月27日
摘要:
作用:使不同的类之间进行协调配合(220V的电压经过适配器给12V的电脑供电) Adapt模式有以下两种: 1.类适配器模式(使用继承的适配器) UML类图: Banner类: print接口: PrintBanner类: 主函数: 2.对象适配器模式(使用委托的适配器) UML类图: print类
阅读全文
posted @ 2019-04-27 11:32
么么打123
阅读(170)
推荐(0)
摘要:
作用:遍历整个集合 UML类图 Aggregate接口: Iterator接口: Book类: BoolShelf类: BookShelfIterator类: 各个角色的作用: Aggregate接口:各个需要迭代器的类都从该类继承方法并去实现 Iterator接口:抽象接口的方法,让实例的迭代器类
阅读全文
posted @ 2019-04-27 10:43
么么打123
阅读(152)
推荐(0)
2019年3月12日
posted @ 2019-03-12 15:14
么么打123
阅读(487)
推荐(0)