自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(103)
  • 资源 (1)
  • 收藏
  • 关注

原创 自己动手写php扩展-类和接口

1.利用php-src提供的工具生成扩展的骨架sudo ./ext_skel.php --ext testclass2.添加类和接口的声明php_testclass.h中PHP_METHOD(TestClass, __construct);PHP_METHOD(TestClass, hello);3.php_testclass.c中static const zend...

2021-03-30 20:41:13 131

原创 87. 扰乱字符串

class Solution { public: bool isScramble(string s1, string s2) { if(s1.length()!=s2.length()) return false; //只要寻找到左边字符集合完整包含右边字符集合,就符合 map<char,int> s1Index,s2Index; int uniq1Numbers=0,uniq2Numbers = .

2020-06-14 23:47:35 204

原创 68. 文本左右对齐

class Solution { public: vector<string> fullJustify(vector<string>& words, int maxWidth) { int lastWordsIndex=-1,//上轮循环处理的最后一个word wordsTotalNow = 0,//当前循环统计的words数量 charsTotalNow=0,//当前循环统计的char数量 c.

2020-06-12 14:40:12 272

原创 42. 接雨水

public: int trap(vector<int>& height) { //1.重点抓住v形,顶点的投影,以及最高点左右分别不同方式计算 //每次遇到新顶点,更新投影,把小于当前投影的数据擦掉,增加当前顶点的投影; //如果当前顶点大于之前所有的投影,则计算数据(最高和第二高决定雨水量),并且擦掉低于该顶点的投影 //2.分治;找到最高点,并以此划分左右两部分,分别计算左右两部分; //左.

2020-06-10 15:17:17 132

原创 41. 缺失的第一个正数

public: int firstMissingPositive(vector<int>& nums) { //有个规律需要思考出来:这个最小数字,肯定处于1~n+1之间 //0-n-1 存储 1-n 之间的数字。 //最后来一次遍历,如果存在缺失,则缺失的即为所求;否则,n+1即为所求 //存储的过程,可以描述为:下标从0-n-1遍历数组,如果符合nums[i-1]==i,则继续, //否则,sw.

2020-06-10 15:16:20 93

原创 37. 解数独

public: void solveSudoku(vector<vector<char> >& board) { if(board.size()<=0 && board[0].size()<=0){ return; } int rowLimits[board.size()][9]; int colLimits[board[0].size()...

2020-06-10 15:11:00 137

原创 22. 括号生成

public: //重点:leftNum >= rightNum 限制条件 vector<string> generateParenthesis(int n) { vector<string> rets; string parenthesis = ""; //2*n个字符;简单的二分即可。 generateParenthesis(n,0,0,parenthesis,rets); r.

2020-06-10 15:05:55 131

原创 10. 正则表达式匹配

public: bool isMatch(string s, string p) { int sLength=s.length(),pLength = p.length(),i=0,j=0;//i,s的逆序号,j,p的逆序号 bool dp[sLength+1][pLength+1];//s尾部和p尾部字符串的匹配数组,0-slength,0-plength for (int i = 0; i <= sLength; ...

2020-06-10 14:56:11 160

转载 转:nginx源码学习资源(不断更新)

nginx源码学习是一个痛苦又快乐的过程,下面列出了一些nginx的学习资源。 首先要做的当然是下载一份nginx源码,可以从nginx官方网站下载一份最新的。看了nginx源码,发现这是一份完全没有注释,完全没有配置文档的代码。 现在你最希望要的是一份注释版的nginx源码,可以从下面的链接中下载一份:https://github.com/jianfengye/nginx...

2019-02-15 18:28:21 113

原创 php-fpm源码浅析

php-src/sapi/fpm/fpm/fpm.c关于fpm初始化关键代码 0 &gt; fpm_php_init_main() || 0 &gt; fpm_stdio_init_main() || 0 &gt; fpm_conf_init_main(test_conf, force_daemon) || 0 &g...

2019-02-13 10:39:27 493

原创 resty中redis返回空

resty中对于redis查询不存在的键,返回的空是USERDATA类型,需额外处理,转为boolean是true;

2019-01-23 15:42:07 434

原创 php中ZTS

1.ZTS zend thread safety,php线程安全,适用于Apache2+worker MPM2.ts_allocate_id:allocates a new thread-safe-resource id;函数 TSRM_API ts_rsrc_id ts_allocate_id(ts_rsrc_id *rsrc_id, size_t size, ts_allocate_cto...

2018-12-16 17:39:15 2912

原创 fastcgi协议管窥

纪录的通用结构:typedef struct { unsigned char version; unsigned char type; unsigned char requestIdB1; unsigned char requestIdB0; unsigned char c...

2018-12-09 22:25:00 148

转载 技术-转发

http://blog.csdn.net/xiaofei_hah0000/article/details/8984192    服务器的想法http://blog.csdn.net/laoyi19861011/article/category/831215  libevent手册http://blog.csdn.net/v_july_v/article/details/6284050 算法...

2018-11-29 19:38:12 163

原创 gdb 调试 php-cp扩展 redisProxy与pool_server的长连接

 1.安装gdb sudo apt-get install gdb2.进入php-cp扩展目录(已经编译过了),源码https://github.com/swoole/php-cp获取要调试函数的真实函数名 zim_redis_connect_pool_select$ nm connect_pool.so....0000000000012170 t zim_re...

2018-10-24 19:13:55 583

转载 转:linux常用的监控命令

1.  top显示所有正在运行而且处于活动状态的实时进程, 而且会定期更新显示结果;它显示了CPU使用率,内存使用率,交换内存使用大小,调整缓存使用大小,缓冲区使用大小,进程PID, 使用的命令等信息。 2.  vmstat一般是通过两个数字参数来完成的,第一个参数是采样时间间隔,单位是秒, 第二个参数是采样的次数r:    表示运行队列,如果队列过大说明CPU很繁忙,一般...

2018-10-10 12:11:00 145

原创 centos7忘记密码

1.进入grub修改,启动后按e2.mount -o remount,rw /3.依次输入以下命令进行root密码修改chroot /sysroot/再输入touch / .autorelabel (touch、/、.autorelabel有空格)最后 passwd root  依次键入你的密码 4.重启,选择用户名,输入密码 ...

2018-09-29 14:33:58 173

原创 php源码之DateTime类

1.声明在php_date.h/* Advanced Interface */PHP_METHOD(DateTime, __construct);PHP_METHOD(DateTime, __wakeup);PHP_METHOD(DateTime, __set_state);PHP_METHOD(DateTime, createFromImmutable);/*其他方法,以映射的方...

2018-09-21 18:44:32 392

原创 自己动手写php扩展

1.下载最新版php源码git clone https://github.com/php/php-src2.切换到ext目录cd php-srccd ext 3.利用php-src提供的工具生成扩展的骨架./ext_skel.php --ext test便可以在当前目录查看到test文件夹--扩展的文件夹./ext_skel.php具体怎么使用,可在当前目录输...

2018-09-20 23:33:49 503

原创 PHP源码之date函数

date函数的实现在源码目录的 ext/date。1.定义函数的参数表:ZEND_BEGIN_ARG_INFO_EX(arginfo_date, 0, 0, 1) ZEND_ARG_INFO(0, format) ZEND_ARG_INFO(0, timestamp)ZEND_END_ARG_INFO()将其展开,得到#define ZEND_ARG_INFO(pass_...

2018-09-13 19:15:34 523

原创 php内核寻找ini的优先过程

php_init_config函数的作用是读取php.ini文件,设置配置参数,加载zend扩展并注册PHP扩展函数。此函数分为如下几步: 初始化参数配置表,调用当前模式下的ini初始化配置,比如CLI模式下,会做如下初始化:INI_DEFAULT("report_zend_debug", "0");INI_DEFAULT("display_errors", "1");不过在其它模式下...

2018-08-23 16:32:37 324

原创 redis源码中的ziplist zskiplist 压缩表和跳表

在压缩双链表中,节省了前驱和后驱指针的空间,在 64 位机器上共节省了 8 个字节, 这让数据在内存中更为紧 凑。只要清晰的描述每个数据项的边界,就可以轻易得到前驱后 驱数据项的位置,ziplist 就是这么做的。 ziplist 的格式可以表示为:&lt;zlbytes&gt;&lt;zltail&gt;&lt;zllen&gt;&lt;entry&gt;...&lt;entry&gt;&l...

2018-08-23 16:32:26 2394

原创 php 内核hashtable中 pListNext和pNext的区别

pListNext指示在php数组中加入的先后顺序pNext指在存储的同一个bucket(链表法解决冲突)中的链表先后位置,注意是头插法,所以越后加入的元素在同一bucket中的位置越靠前;...

2018-08-23 16:20:03 652

原创 redis pipeline 和 multi

redis的pipeline是批量操作,以提高性能为主,无法保证原子性;multi  watch  exec  discard unwatch  主要针对原子性,性能会有所下降

2018-08-07 11:12:01 630

原创 leetcode125. Valid Palindrome

class Solution {public:    bool isPalindrome(string s) {        int head = 0;        int tail = s.size() - 1;        if(tail&lt;0) return true;        while(head&lt;=tail){            if(!((s[head]&gt...

2018-03-14 19:11:37 117

原创 123. Best Time to Buy and Sell Stock III

class Solution {public:    int maxProfit(vector&lt;int&gt;&amp; prices) {                vector&lt;vector&lt;int&gt;&gt; maxProfits(prices.size(),vector&lt;int&gt;(2,0));        int maxPos = prices.si...

2018-03-14 18:49:00 105

原创 122. Best Time to Buy and Sell Stock II

class Solution {public:    int maxProfit(vector&lt;int&gt;&amp; prices) {                int maxPos = prices.size() - 1;        if(maxPos &lt; 0 ) return 0;                int maxTemp = 0 ;//短线的上升沿最大值...

2018-03-14 16:30:47 107

原创 121. Best Time to Buy and Sell Stock

class Solution {public:    int maxProfit(vector&lt;int&gt;&amp; prices) {        vector&lt;vector&lt;int&gt;&gt; maxProfits(prices.size(),vector&lt;int&gt;(2,0));        int maxPos = prices.size() - 1...

2018-03-14 15:18:13 120

原创 leetcode120. Triangle

class Solution {public:    int minimumTotal(vector&lt;vector&lt;int&gt;&gt;&amp; triangle) {        if(triangle.size()&lt;=0) return 0;        int k = triangle.size() - 1;        vector&lt;int&gt; res...

2018-03-13 16:35:54 161

原创 leetcode119. Pascal's Triangle II

class Solution {public:    vector&lt;int&gt; getRow(int rowIndex) {        vector&lt;int&gt; result(rowIndex+1);        int cursor = 1;        result[0] = 1;                int smallCursor = 1;       ...

2018-03-13 15:41:36 142

原创 leetcode118. Pascal's Triangle

class Solution {public:    vector&lt;vector&lt;int&gt;&gt; generate(int numRows) {        vector&lt;vector&lt;int&gt;&gt; result;                if(numRows&lt;=0) return result;        result.push_bac...

2018-03-13 14:03:58 114

原创 117. Populating Next Right Pointers in Each Node II

class Solution {public:    void connect(TreeLinkNode *root) {        if(root==NULL) return ;        TreeLinkNode *start = root;        TreeLinkNode *rootcur  = start;        TreeLinkNode *tail=NULL;  ...

2018-03-13 12:07:32 95

原创 116. Populating Next Right Pointers in Each Node

class Solution {public:    void connect(TreeLinkNode *root) {        if(root==NULL) return ;        TreeLinkNode *start = root;        TreeLinkNode *cur  = start;        while(start){            cur =...

2018-03-13 12:06:41 117

原创 leetcode115. Distinct Subsequences

class Solution {public:    int numDistinct(string s, string t) {        if(t.size()&lt;=0) return 1;        if((s.size()&lt;=0 &amp;&amp; t.size()&gt;0) || s.size()&lt;t.size()){            return 0; ...

2018-03-08 19:32:09 144

原创 114. Flatten Binary Tree to Linked List

class Solution {public:    void flatten(TreeNode* root) {        if(root==NULL) return ;        flattenTree(root);    }    TreeNode* flattenTree(TreeNode* root) {        if(root==NULL) return NULL;   ...

2018-03-07 15:39:30 124

原创 113. Path Sum II

class Solution {public:    vector&lt;vector&lt;int&gt;&gt; pathSum(TreeNode* root, int sum) {        vector&lt;vector&lt;int&gt;&gt; result;        vector&lt;int&gt; temp;        pathSum(root,sum,temp...

2018-03-07 14:56:10 92

原创 112. Path Sum

class Solution {public:    bool hasPathSum(TreeNode* root, int sum) {        if(root==NULL)  return false;                if(root-&gt;left==NULL &amp;&amp; root-&gt;right==NULL){            if(sum == ...

2018-03-07 14:30:39 120

原创 111. Minimum Depth of Binary Tree

class Solution {public:    int minDepth(TreeNode* root) {        if(root==NULL) return 0;        if(root-&gt;left==NULL &amp;&amp; root-&gt;right==NULL){            return 1;        }        if(root-&...

2018-03-07 14:17:57 97

原创 110. Balanced Binary Tree

class Solution {public:    bool isBalanced(TreeNode* root) {        if(root==NULL) return true;        int left = treeDiffer(root-&gt;left);cout&lt;&lt;left&lt;&lt;endl;        int right = treeDiffer(...

2018-03-06 19:25:33 99

原创 109. Convert Sorted List to Binary Search Tree

class Solution {public:    TreeNode* sortedListToBST(ListNode* head) {        ListNode* tail = head;        ListNode* middle = head;        while(tail!=NULL&amp;&amp;tail-&gt;next!=NULL){            t...

2018-03-06 18:42:28 114

Artificial Intelligence - A Modern Approach 3

Artificial Intelligence - A Modern Approach 3 人工智能 一种现代的方法第3版

2017-10-25

空空如也

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

TA关注的人

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