自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(308)
  • 收藏
  • 关注

原创 numpy 向量化计算IOU

def IoU(bbox, gt): """ :param bbox: (n, 4) :param gt: (m, 4) :return: (n, m) numpy 广播机制 从后向前对齐。 维度为1 的可以重复等价为任意维度 eg: (4,3,2) (3,2) (3,2)会扩充为(4,3,2) (4,1,2) (3,2)...

2020-02-24 18:14:21 1360 3

原创 mqtt协议理解

1. 应用场景: 低带宽,数据头尽可能小。2. 属于应用层协议,采用TCP承载。3. 采用 发布-> (代理) -> 订阅模式(利用中间代理实现了异步通讯),发布方发送的相当于是个广播信息, 设置一个主题。订阅方根据主题选择自己订阅的报文。不过是发布方还是订阅方都看作broker(代理)的客户端,采用mqtt协议通讯。4. 报文结构控制头(1字节)包...

2019-12-24 11:27:27 486

原创 source cmd

source是执行一个文件在当前shell中生效, 而用./filename或者sh filename 都是相当于额外开一个shell执行(执行结果在当前shell中不生效) 所以一般用户配置文件生效方式会采用 source ~/.bash_profile。测试方法: 编写tmp.sh 内容为export test=2, 使用sh tmp.sh 时, echo $test为空, 使用...

2019-12-11 10:49:27 711

原创 centos nvidia驱动升级

1. yum remove nvidia-kmo2. 参考http://elrepo.org/tiki/tiki-index.php添加repo url。3. yum installkmod-nvidia-390xx( 自己选择相应版本)4. reboot (或者参考https://comzyh.com/blog/archives/967/杀掉所有nvidia相关进程然后重新加载...

2019-12-10 16:49:36 1454

原创 go 协程控制

参考go协程控制方式有 waitGroup, select+chan(类似epoll), context三种。 waitGroup类似于消费者模型,使用ADD() 方法指定初始产品数量,使用Done()方法消费一个物品,使用Wait()表示直到物品数量消费到0为止 ,否则一直阻塞。 select就是对管道进行选择,哪个管道中写入了数据就选择哪个,多个同时写入的话随机选择。...

2019-11-04 11:42:47 748

原创 go第三方包管理

1. 传统方法 GOPATH 项目代码放在gopath/src目录下,使用go get 安装第三方库时会把源代码放在src, 然后执行go install 即对src代码build后把可执行文件放在bin目录下。2. go mod 使用go mod时,项目代码不应该放在gopath/src/目录下。使用go mod download会自动下载依赖包。...

2019-10-25 20:42:56 641

原创 ssl通信

必要知识:假设通信方是甲和乙1. 对称加密算法加密解密用同一个秘钥,速度快2. 非对称加密使用公钥加密,私钥解密。或者私钥加密公钥解密, 速度慢。3. 公钥在网上可以自由交换,私钥自己保留。4. CA是甲乙都信任的,通信方把自己公钥交由CA生成证书,另一方确认证书是自己信任的CA机构颁发并且没有被篡改。上图是甲向乙发送数据时的过程。甲对数据部分生成摘要,用甲私钥加密...

2019-10-24 20:25:38 163

原创 笔记

linux 虚拟路由器开启一个net namespace 通过设立iptables转发规则go 为什么适合高并发传统并发 (进程/线程 在内核态) 遇到阻塞(加锁)时发生线程切换,涉及到上下文切换耗时而协程切换发生在用户态 只涉及到一部分寄存器...

2019-09-29 21:23:19 101

原创 docker 通信

一、NAT转换NAT一般是内网转公网的一个网关, 内网对外表现为一个公网IP地址(不考虑嵌套情况),内网IP数据报经过NAT时通过转换为公网IP地址 通过端口号区分。二、veth pair相当于是一根虚拟的网线(虚拟的好处是不用通过实实在在的网络设备转发 而是直接在内核中进行数据的复制)可以用来连接两个不同的Net Namespace三、docker之间通信do...

2019-09-22 15:58:55 262

原创 linux管道 如何理解一切皆文件

一、linux文件类型 (涉及到I/O的都可以抽象为文件)1.普通文件 # xxx.log2.目录 # /usr/ /home/3.字符设备文件 # /dev/tty的属性是 crw-rw-rw- ,注意前面第一个字符是 c ,这表示字符设备文件,比如猫等串口设备4.块设备文件 # /dev/hda1 的属性是 brw...

2019-09-21 19:24:00 424

原创 golang 协程通信

func finish(ch chan int){ fmt.Println("finish") ch <- 1}func main() { // 无缓冲管道 写入后一直阻塞到有人读出 // 或者在没有数据时读取也会阻塞 // 采取缓冲信道后变成生产者消费者模型 只有在空或者满时才会发生阻塞 ch := make(chan int) go finish(ch) fmt...

2019-09-16 14:33:40 420

原创 golang切片及变参传值 指针

**** 理解切片ptr指向了一块内存区域 大小是cap 实际存放的内容大小是len 每次执行切片后相当于存放了一个指向该位置的索引结构 故修改值会相互影响 是一种引用在创建数组时没有指定大小即是创建切片 。或者声明了一个数组后 从数组中再进行切片*** 变参func addandsub(a int, b int) (int, int){ return a + b , ...

2019-09-15 21:39:25 1468

原创 golang 面向对象

type Animal interface { // 这里可以嵌入(或者说组合)别的接口 speak() big() bool}// struct 中只定义成员变量 interface 只定义方法// 在外面定义了interface 中所有的方法后就可看做实现了interface这就是ducktype// duck_type 实现了这个接口的所有方法就是这个接口(走起来是鸭子叫起...

2019-09-15 19:24:59 1497

原创 goLang闭包理解

闭包是为了在函数内部捕获外部变量(不声明为全局变量)例如实现一个计数器 从base开始 每调用一个加一在c++ 中可以采用仿函数,在调用构造函数时传入base 或者使用lambda函数,捕获base变量class fun{private: int base;public: fun(int _base):base(_base){} int operator(...

2019-09-15 16:04:46 300

原创 go基础

变量定义1. 声明类型 不赋初值 (采用默认值 eg: sring "" int 0)var name bool 2. 赋值a := 15 同时定义多个变量var(a int; b bool)a, b:= 20, 16切片和数组之间的关系切边是数组的一个引用, 对数组的切片相当于声明了一个索引范围在定义时 没有生命容量的是创建切片 否则是数组...

2019-09-15 14:11:43 120

原创 c++ const关键字总结 以及valgrind使用

常对象只能访问常成员函数(访问非常成员函数肯能会改变自己的值)使用g++ 编译test.c 加上-g选项 在使用valgrind是就能定位到源代码中的位置valgrind --tool=memcheck --leak-check=yes --show-reachable=yes ./test...

2019-09-11 21:37:01 172

原创 c++11 unkown总结

static_cast 类似于c中强制转型 也能把父类型强制转为子类型(不安全 指针不能访问子类型中的函数)在编译时检查dynamic_cast 在运行时会检查 如果转换不合理 对于指针类型会返回NULLclass T{public: virtual void t(){}};class B:public T{public: void fun(){cout<...

2019-09-11 20:31:32 1971

原创 typename和class一点点区别

使用typename T::bartype bar 表示使用这一类型namespace test{ /* traits 是为了获取迭代器指向值的类型 在迭代器中放入value_type * traits 是一个只包含类型定义的模板类 * 为了泛化 即使得一般的指针也能使用可以使用类模板的偏特化版本 即针对真指针类型的 * 迭代器视为伪指针类型 实现...

2019-09-10 20:47:11 270

原创 Max Sum of Rectangle No Larger Than K(二维矩阵求最小子矩阵和 以及小于等于k的LIS)

Given a non-empty 2D matrixmatrixand an integerk, find the max sum of a rectangle in thematrixsuch that its sum is no larger thank.Example:Input: matrix = [[1,0,1],[0,-2,3]], k = 2Output: ...

2019-09-06 20:52:41 231

原创 Count Numbers with Unique Digits(排列组合)

Given anon-negativeinteger n, count all numbers with unique digits, x, where 0 ≤ x < 10n.Example:Input: 2Output: 91 Explanation: The answer should be the total numbers in the range of 0 ≤ ...

2019-09-06 16:39:49 221

原创 Palindrome Pairs (暴力匹配不如查找)

Given a list ofuniquewords, find all pairs ofdistinctindices(i, j)in the given list, so that the concatenation of the two words, i.e.words[i] + words[j]is a palindrome.Example 1:Input: ["...

2019-09-06 16:11:41 108

原创 Verify Preorder Serialization of a Binary Tree(搭配流处理分隔字符串)

One way to serialize a binary tree is to use pre-order traversal. When we encounter a non-null node, we record the node's value. If it is a null node, we record using a sentinel value such as#. ...

2019-09-06 14:58:16 62

原创 Reconstruct Itinerary(求欧拉路径)

Given a list of airline tickets represented by pairs of departure and arrival airports[from, to], reconstruct the itinerary in order. All of the tickets belong to a man who departs fromJFK. Thus, th...

2019-09-05 17:03:43 146

原创 Maximum Product of Word Lengths

Given a string arraywords, find the maximum value oflength(word[i]) * length(word[j])where the two words do not share common letters. You may assume that each word will contain only lower case lett...

2019-09-04 17:29:59 70

原创 Russian Doll Envelopes 以及LIS 二分查找解法

You have a number of envelopes with widths and heights given as a pair of integers(w, h). One envelope can fit into another if and only if both the width and height of one envelope is greater than th...

2019-09-04 14:51:12 114

原创 Integer Break

Given a positive integern, break it into the sum ofat leasttwo positive integers and maximize the product of those integers. Return the maximum product you can get.Example 1:Input: 2Output: 1...

2019-09-03 22:15:03 122

原创 Scramble String

Given a strings1, we may represent it as a binary tree by partitioning it to two non-empty substrings recursively.Below is one possible representation ofs1="great": great / \ gr ...

2019-09-03 21:19:51 84

原创 Interleaving String

Givens1,s2,s3, find whethers3is formed by the interleaving ofs1ands2.Example 1:Input: s1 = "aabcc", s2 = "dbbca", s3 = "aadbbcbcac"Output: trueExample 2:Input: s1 = "aabcc", s2 = "...

2019-09-03 19:52:23 146

原创 range module

A Range Module is a module that tracks ranges of numbers. Your task is to design and implement the following interfaces in an efficient manner.addRange(int left, int right)Adds the half-open int...

2019-09-03 19:27:56 133

原创 二分查找的规范写法

值唯一时值不唯一时 返回到第一个大于等于这个数的位置即上边界和给定元素相同时也要缩减上边界 最后上边界和下边界重合时得到第一个大于等于给定元素的位置当然 查找到这个位置 后还要进一步判断是否和给定值相同...

2019-09-01 17:58:48 202

原创 KMP

/* 求next数组就是自己和自己匹配 * next数组表示 相等的最长前缀和后缀的长度 同时也等于失配后跳到的下一个位置!长度=索引+1 * 自己A和自己B匹配时要错开一位开始进行匹配 (不然A和B上来就是完全匹配的) * */vector<int> Next(string &pattern){ int i=0, j=-1, len=pattern.leng...

2019-08-31 22:18:19 61

原创 c++ const

const是C语言的一种关键字,起受保护,防止以外的变动的作用!可以修饰变量,参数,返回值,甚至函数体。const可以提高程序的健壮性,你只管用到你想用的任何地方。 (一)const修饰参数。const只能修饰输入参数。 1、如果输入参数是指针型的,用const修饰可以防止指针被意外修改。 2、如果参数采用值传递的方式,无需const,因为函数自动产生临时变量复制该参数。 3、非内部数据类型的参...

2019-08-31 18:55:17 117

原创 C++ 虚表

每个类有个有自己的虚表 每个对象有个指针__vptr指向自己类的虚表int main(){ B bObject; A *p = & bObject; p->vfunc1();}在调用时 用父类的指针(这样当要指向子类时相当于自动转型) p指向bObject p调用vfunc1 会找bObject所在类的虚表同理:int main()...

2019-08-31 16:25:47 132

原创 宏定义的理解

首先: c/c++ 编译可以用gcc 连接要用g++ (gcc 不能调用c++库链接)#include<iostream>using namespace std;int main(){#ifdef DEBUG cout<<"DEBUG"<<endl;#else cout<<"RELEASE"<<endl;#endif...

2019-08-26 17:06:54 236

原创 c++ functor用处!!!

某些特殊场景: 函数中包含一些要赋的值 但是函数只能传入一个参数例如使用count_if 来得到长度大于len的字符的个数class ShorterThan { public: explicit ShorterThan(int maxLength) : length(maxLength) {} bool operator() (const str...

2019-08-26 16:55:48 318

原创 Remove Duplicate Letters

Given a string which contains only lowercase letters, remove duplicate letters so that every letter appears once and only once. You must make sure your result is the smallest in lexicographical order ...

2019-08-23 15:37:26 250

原创 c++ unqiue 配合erase 去重

unique “去除相邻的相同元素” 实际并未去除 只是把不重复的依次移动到了前面 实现方法如下:iterator My_Unique (iterator first, iterator last){ if (first==last) return last; iterator result = first; while (++first != last) { ...

2019-08-21 19:30:32 531

原创 Segment Tree vs Binary Index Tree

二者都适用于区间和询问的问题 只是一个动态分配内存实现 一个靠数组实现/*线段树 记录了一个区间性质的东西 * 例如 区间求和 (但是求众数不行 ) * 操作:建树 build 点修改 modifu 区间求和sum * 类似于之间自己手写二分查找树的记录过程 (也不完全相同) * 对于叶子节点的父亲 在递归时左边是[left, mid] 右边是[mid+1, right] 左边...

2019-08-21 19:07:23 176

原创 Additive Number(大数加法+递归拆分判断)

Additive number is a string whose digits can form additive sequence.A valid additive sequence should containat leastthree numbers. Except for the first two numbers, each subsequent number in the s...

2019-08-19 20:52:12 220

原创 Minimum Height Trees

For an undirected graph with tree characteristics, we can choose any node as the root. The result graph is then a rooted tree. Among all possible rooted trees, those with minimum height are called min...

2019-08-19 19:33:23 113

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除