base

shared_ptr 用法

时光怂恿深爱的人放手 提交于 2019-11-29 03:21:37
引入 shared_ptr 是c++为了提高安全性而添加的智能指针,方便了内存管理。 特点 shared_ptr 是通过指针保持对象共享所有权的智能指针。多个 shared_ptr 对象可占有同一对象。这便是所谓的引用计数(reference counting)。一旦最后一个这样的指针被销毁,也就是一旦某个对象的引用计数变为0,这个对象会被自动删除。这在非环形数据结构中防止资源泄露很有帮助。使得指针可以共享对象,并且不用考虑内存泄漏问题 shared_ptr 可以支持普通指针的所有操作,完全可以像操作普通指针一样操作智能指针。 shared_ptr 可以通过三种方式得到(拷贝初始化,定义delete操作的方式不在罗列,只讨论初始化指针所指对象来源): 1.通过一个指向堆上申请的空间的指针初始化(切记不要用栈上的指针,否则,当智能指针全部释放控制权(栈中的对象离开作用域本身就会析构一次),将会析构对象,导致出错) 2.通过make_shared函数得到 3.通过另外一个智能指针初始化 int *a = new int(8); std::shared_ptr<int> p1(a); auto b = std::make_shared<int>(2); auto c(b); 注意事项 1. 使用原生指针多次初始化 class Base { public: Base() { printf(

栈的基本算法

喜欢而已 提交于 2019-11-29 03:21:10
一、简单介绍 栈是限定进在表尾插入或删除操作的线性表。因此,对栈来说,表尾端有其特殊的含义,成为栈顶(top),相应地,表头端称为栈底(bottom)。 不含元素的空表称为空栈。 栈的修改是按照后进先出的原则进行的,因此,栈又称为后进先出的线性表。 二、栈示意图 三、基本操作 1、栈的初始化: InitStack(&S) 2、栈顶元素插入: Push(&S, &e) 3、栈顶元素获取: GetTop(&S, &e) 4、栈顶元素删除: Pop(&S, &e) 5、栈的长度: StackLength(S) 6、栈的判空: StackEmpty(S) 7、栈元素的访问: StackTraverse(S, visit()) 8、栈的清空: ClearStack(&S) 9、栈的销毁: DestroyStack(&S) 四、栈顺序存储的实现 //---------- 栈的顺序存储表示 --------- #define STACK_INIT_SIZE 100; //存储空间初始分配量 #define STACKINCREMENT 10; //存储空间分配增量 typedef struct { SElemType *base; //在栈构造之前和销毁之后,base的值为NULL SElemType *top; //栈顶指针 int stacksize; //当前已分配的存储空间,以元素为单位

What's your best trick to break out of an unbalanced quote condition in BASE SAS?

我的梦境 提交于 2019-11-28 23:45:15
As a base SAS programmer, you know the drill: You submit your SAS code, which contains an unbalanced quote, so now you've got not only and unclosed quote, but also unclosed comments, macro function definitions, and a missing run; or quit; statement. What's your best trick for not having those unbalanced quotes bother you? enterprise guide 3 used to put the following line at the top of its automatically generated code: *';*";*/;run; however, the only way to really "reset" from all kinds of something unbalanced problems is to quit the sas session, and balance whatever is unbalanced before re

How do I set a page's base href in Javascript?

老子叫甜甜 提交于 2019-11-28 22:32:51
问题 I want to set a page's base href attribute in Javascript based off of the current hostname. I have generated HTML pages that can be viewed on different hostnames, which means generating a base href tag will work in one hostname but will be incorrect in the other. 回答1: The correct way of doing this is to do a document.write of the tag based off the current hostname: Correct: <script type="text/javascript"> document.write("<base href='http://" + document.location.host + "' />"); </script> This

python3 super().__init__() 和 __init__() 的区别

徘徊边缘 提交于 2019-11-28 21:50:45
1、单继承 super().__int__()和 Base.__init__(self)是一样的, super()避免了基类的显式调用。 class Base(object): def __init__(self): print('Create Base') class ChildClassA(Base): def __init__(self): super().__init__() print('Create ChildClassA') ChildClassA() #输出 #Create Base #Create ChildClassA 来源: https://www.cnblogs.com/AndyChen2015/p/11428212.html

why base tag does not work for relative paths?

≯℡__Kan透↙ 提交于 2019-11-28 18:08:37
I have a BASE tag as below in head section of the page: <base href="http://localhost/framework"> And a script as below which is relative (of course after base tag): <script src="/assets/jquery-1.7.1.min.js"> But when I open jQuery from firebug it shows: <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> <html><head> <title>404 Not Found</title> </head><body> Blah Blah Blah.... When I use the below link it's OK though: <script src="http://localhost/framework/assets/jquery-1.7.1.min.js"> I looked for answer everywhere, but it seems I'm doing my job right! So what is the problem? /assets/jquery-1

Django-4

青春壹個敷衍的年華 提交于 2019-11-28 17:45:23
母版和继承: 优点:将多个共用的部分提取出来,减少代码的复用率 使用步骤: 1.共用的html部分提取出来,放在一个base页面里面 2.在base.html页面上,通过定义block,来指定在什么地方添加新的东西 3.在具体的页面上,先继承母版{% extends 'base.html'%} 4.然后在block中填写指定的页面 注意事项: 1.{%extends 'base.html'%} 母版文件要加引号 2.{%extends 'base.html'%} 必须放在页面的第一行 3.可以在base.html中定义很多个block,通常我们会额外的定义一个page-css, page-js 组件: include 在母版里面可以随便放,但是在继承里面需要在block 里面 静态文件的路径问题: 在Templates下的HTML文件中,如果要引用static下的静态文件 {% load static%} <link rel='stylesheet' href='{% static 静态文件的路径%}'> 此方法解决了,不同的人的不同命名习惯带来的路径找不到的问题 来源: https://www.cnblogs.com/FlowerNotGiveYou/p/11417400.html

Add density lines to histogram and cumulative histogram

无人久伴 提交于 2019-11-28 17:37:52
I want to add density curve to histogram and cumulative histogram, like this: Here is as far I can go: hist.cum <- function(x, plot=TRUE, ...){ h <- hist(x, plot=FALSE, ...) h$counts <- cumsum(h$counts) h$density <- cumsum(h$density) h$itensities <- cumsum(h$itensities) if(plot) plot(h) h } x <- rnorm(100, 15, 5) hist.cum(x) hist(x, add=TRUE, col="lightseagreen") # lines (density(x), add = TRUE, col="red") Offered without explanation: ## Make some sample data x <- sample(0:30, 200, replace=T, prob=15 - abs(15 - 0:30)) ## Calculate and plot the two histograms hcum <- h <- hist(x, plot=FALSE)

基于Nios II的LCD16027驱动实例

徘徊边缘 提交于 2019-11-28 17:37:16
实验平台:DE2-115 软件版本:Quartus II 15.1 为节约时间,Qsys中系统的搭建就不啰嗦了,直接贴图。 DE2-115中SDRAM的配置如下图所示: Hardware code: 1 module LCD1602( 2 clk, 3 rst_n, 4 led, 5 lcd1602_RS, 6 lcd1602_RW, 7 lcd1602_data, 8 lcd1602_E, 9 sdram_addr, 10 sdram_ba, 11 sdram_cas_n, 12 sdram_cke, 13 sdram_cs_n, 14 sdram_dq, 15 sdram_dqm, 16 sdram_ras_n, 17 sdram_we_n, 18 sdram_clk, 19 lcd1602_vl, 20 lcd1602_on 21 ); 22 23 input clk; 24 output lcd1602_RS; 25 output lcd1602_RW; 26 inout [7:0] lcd1602_data; 27 output lcd1602_E; 28 output lcd1602_vl; 29 output lcd1602_on; 30 31 input rst_n; 32 output[12:0]sdram_addr; 33 output[1:0] sdram

Search in SVN repository for a file name

谁说胖子不能爱 提交于 2019-11-28 15:54:25
问题 We have a bulk repository for code contain thousands of folder and sub folder, i want to search under this repositor with file name or with some word. Root folder a\ b\ c\ d\ e\ f\ab\ f\ab\cd.txt I want to search for cd.txt but dont know where it is in SVN Repository, for that i want to perform a search on the root folder of SVN where i will put the file name cd.txt and run the command, will check in each folder and will display the file details result.... Hope requirement is clear. Can you