自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(85)
  • 资源 (10)
  • 收藏
  • 关注

原创 go net.conn SetReadDeadline的困惑

最近在用go写个工具,在几百个协程并行拿多个服务器数据时,用SetReadDeadline设置超时60s时,经常read返回失败,错误信息是timeout,而不设置SetReadDeadline时,反而正常,而且正常数据返回也不可能会超时60s,这是为什么呢?

2023-04-23 14:04:00 680 2

原创 短时间大量连接时,服务对外端口不能访问的问题

最近一个服务在早上有大量连接,超过22w,连上时,会有对外服务不能访问问题,从而导致被云检查关闭重启的问题,经查出,是内核一参数设置过小导致,当有大量连接超过时,超出的连接会被丢弃。net.nf_conntrack_max 和net.netfilter.nf_conntrack_max值内核参数 net.nf_conntrack_max 系统默认值为”65536”,当nf_conntrack模块被装置且服务器上连接超过这个设定的值时,系统会主动丢掉新连接包,直到连接小于此设置值才会恢复。同时内核参数

2022-05-26 17:25:44 1802

原创 concurrentqueue无锁队列多线程无序问题

最近接触了concurrentqueue的多线程无锁队列,测试了一下,发现单线程生产者和单线程消费者可以正常使用,多线程生产者的时候,即使加锁了,单线程取出来的时候好像还是无序的#include <iostream>#include "concurrentqueue.h"#include <functional>#include <thread>#include <mutex>using moodycamel::ConcurrentQueue;

2022-02-24 14:59:12 1373 1

转载 定时器timer_create timerfd_create

一、timer_create进程可以通过调用timer_create()创建特定的定时器,定时器是每个进程自己的,不是在fork时继承的,不会被传递给子进程。编译时加编译选项 -lrt。包含头文件<time.h>1. timer_createint timer_create(clockid_t clockid, struct sigevent *sevp, timer_t *timerid);参数:(1) clockid定义了定时器计时的方法,有如下几个值: CL...

2022-02-24 14:04:19 8961

原创 数组中连续子数组最大和

使用动态规划解法:#include <stdio.h>#include <stdlib.h>int MaxSum(int *nums, int len){ int sum = nums[0]; int n = nums[0]; for(int i=1; i < len; i++) { if(n > 0) n+= nums[i]; el...

2021-11-10 17:00:00 202

原创 gcc7.2 with-default-libstdcxx-abi属性

碰到一个在另个系统上用gcc7.2编译时,怎么也找不到一个日志库log4cxx函数定义的问题,在自己的编译机上一切都是正常的,请教另个同事才发现,另个gcc版本加了with-default-libstdcxx-abi属性--with-default-libstdcxx-abi=gcc4-compatibleConfigured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --wi

2021-11-04 15:20:12 478

原创 全排列2,去重复

void dfs(vector<int>& nums, int n, int i, list<int>& cur, list<list<int> >& ret, vector<bool> &flag){ if(i == n) { ret.push_back(cur); return; } ...

2021-10-06 13:46:00 99

原创 数组的全排列

void dfs(int* nums, int n, int i, list<int>& cur, list<list<int> >& ret, vector<bool> &flag){ if(i == n) { ret.push_back(cur); return; } for(int p = 0; p ...

2021-10-06 11:01:48 140

原创 两个数字字符串相乘

使用性质:长为n的数和长为m的数相乘的结果最大长度为m+n; 结果存在数组res中,num1[i]*num2[j]的结果为两位数tmp(0x或者xy),其中第一位位于 res[i+j], 第二位位于res[i+j+1]。 代码: string multiply(string& num1, string& num2) { vector<int> arr1; vector<int> a...

2021-09-11 09:05:32 380

原创 查找缺少的第一个正数

要求算法O(n),只能使用常数级别的额外空间int firstMissNum(int *nums, int len){ for(int i=0; i < len; ) { if(nums[i] >0 && nums[i] < len && nums[i] != nums[nums[i]-1]) { int in...

2021-09-10 16:09:11 73

原创 数组中和等于指定值,不可重复使用

数组中可能会有重复值在上个版本中做优化,去掉重复值,不重复利用void backtrack(vector<int> &candidates, int target, list<vector<int> >&res, int i, vector<int> &tmp_list);void comSum(vector<int>& candidates, int target){ list&lt...

2021-09-08 11:12:33 240

原创 数组中元素组合等于某个值和,可重复使用

利用回朔法,递归,当某个值超出时,移除,再遍历下个值void backtrack(vector<int> &candidates, int target, list<vector<int> >&res, int i, vector<int> &tmp_list);void comSum(vector<int>& candidates, int target){ list<vector...

2021-09-07 17:12:09 307

原创 查找排序数组插入一个值的指定位置

void searchRange(int *arr, int len, int target){ if(len == 0) return; int left = 0; int right = len -1; int ans = len; while(left <= right) { int mid = ((right - left) >> 1) + left...

2021-09-02 16:51:42 77

原创 查找排序数组指定值范围

查找排序数组指定值,会有重复值,找出第一个和最后一个值的位置void searchRange(int *arr, int len, int target){ if(len == 0) return; int left = 0; int right = len -1; while(left <= right) { int mid = (left + right) >> ...

2021-09-02 16:27:54 139

原创 搜索旋转排序数组

在一个旋转排序数组中查找指定值比如4,5,6,7,0,1,2 中搜索0int Search(int *arr, int len, int target){ int l = 0; int r = len; if(r == 0) return -1; int m; while(r > l) { m = (l+r) >> 1; ...

2021-08-30 19:23:13 81

原创 __attribute__作用

__attribute__用法attribute((constructor))在main函数之前,执行一个函数,便于我们做一些准备工作__attribute((constructor))void before(){printf(“before main\n”);}attribute((destructor))在main()函数退出或者调用了exit()之后调用__attribute((destructor))void after(){printf(“before main\n”);}

2021-08-28 10:37:32 270

转载 linux -rpath作用,指定默认库查找路径

转载:https://blog.csdn.net/q1302182594/article/details/42102961/结论:-rpath和-rpath-link都可以在链接时指定库的路径;但是运行可执行文件时,-rpath-link指定的路径就不再有效(链接器没有将库的路径包含进可执行文件中),而-rpath指定的路径还有效(因为链接器已经将库的路径包含在可执行文件中了)。 最后,不管使用了-rpath还是-rpath-link,LD_LIBRARY_PATH还是有效的。可以在编..

2021-08-28 10:09:41 951

原创 最长有效括号长度

int FindMaxStr(const char* s, int len){ int *f = new int[len]; for(int i=0; i < len; ++i) { f[i] = 0; } int i, t, ret = 0; for(i = 1; i < len; ++i) { if(s[i] == ...

2021-08-26 11:02:56 86

原创 获取下一个较小数组

void swap(int i, int j, int *nums){ int temp = nums[i]; nums[i] = nums[j]; nums[j] = temp;}void reverse(int *nums, int len , int index){ int i = index; int j = len -1; while(i < j) { ...

2021-08-23 10:45:40 87

原创 一个字符串,查找字符串列表中,合并后的字串位置

一个字符串,查找字符串列表中,合并后的字串位置1:遍历方法2.优化后的遍历void findSubString(string &s, string* words, int len){ if(len == 0) { return; } int n = s.length(); int word_cnt = len; int m = words[0].length...

2021-08-21 15:37:37 128

原创 实现strstr

int StrStr(string & src, string &dest){ if(src.length() < dest.length()) return -1; for(int i=0; i < src.length() - dest.length(); ++i) { const char* p = src.c_str() + i; ...

2021-08-20 14:28:47 63

原创 删除数组指定值

不借助第三方内存,O(1)int DelValNums(int *arr, int len, int val){ if(len == 0) return 0; int i = 0; for(int j=0; j < len; ++j) { if(arr[j] != val) { arr[i] = arr[j]; ...

2021-08-20 14:15:00 154

原创 删除排序数组中重复的数字

不借助第三方内存,O(1)时间复杂度using namespace std;int DelDupNums(int *arr, int len){ if(len == 0) return 0; int i = 0; for(int j=1; j < len; ++j) { if(arr[j] != arr[i]) { ...

2021-08-20 14:08:38 47

原创 N个一组反转链表

struct Node{ int value; Node* next;};Node* reverse(Node* head, Node* tail){ if(head == NULL || head->next == NULL) return head; Node* pre = NULL; Node* next = NULL; while(pre != tai...

2021-08-20 13:57:32 278

原创 一个Linux程序的执行过程的详解

execve()另一方面,在子进程中会调用execve()加载test并开始执行。这是test被执行的关键,下面我们详细分析一下。execve()是操作系统提供的非常重要的一个系统调用,在很多文章中被称为exec()系统调用(注意和shell内部exec命令不一样),其实在Linux中并没有exec()这个系统调用,exec只是用来描述一组函数,它们都以exec开头,分别是:#includeint execl(const char *path, const char *arg, ...);int

2021-08-19 17:08:56 344

原创 单个链表反转

struct Node{ int value; Node* next;};Node* reverse(Node* head, Node* tail){ if(head == NULL || head->next == NULL) return head; Node* pre = NULL; Node* next = NULL; while(pre != tai...

2021-08-18 19:18:56 55

原创 链表两两交换节点

用的递归的方法struct Node{ int value; Node* next;}Node* SwapPairs(Node* head){ if(head == NULL || head->next == NULL) return head; Node* first = head; Node* second = head->next; first-...

2021-08-16 16:09:11 67

原创 合并N个有序链表

有几种方法,目前只写了每两两合并struct Node{ int value; Node* next;}Node* MergeNode(Node* l1, Node* l2){ Node* temp = new Node(); Node* head = temp; while(l1 && l2) { if(l1.value < l2.valu...

2021-08-16 09:16:43 389

原创 合并排序链表

struct Node{ int value; Node* next;}Node* MergeNode(Node* l1, Node* l2){ Node* temp = new Node(); Node* head = temp; while(l1 && l2) { if(l1.value < l2.value) ...

2021-08-14 13:22:13 74

原创 删除链表倒数N个节点

struct Node{ int value; Node* next;}Node* DelNodeN(Node* head, int n){ Node* head2 = head; while(n>0 ) { head2 = head2->next; if(head2 == NULL) { ...

2021-08-14 11:22:11 41

原创 最接近值三数之和

int FindMinSum(vector<int> &arr, int len, int target){ std::sort(arr.begin(), arr.end()); int ans = 0; if(arr.size() <=3) { for(int i=0; i < arr.size(); ++i) { ...

2021-08-14 10:43:47 49

原创 三数之和等于指定值

struct _Two{ int i; int j;};struct _Three: public _Two{ int k;};void TwoSum(int *arr, int start, int end, int firstvalue, int target, vector<_Three> &result){ map<int, int> testMap; for(int i=start;...

2021-08-14 10:15:04 195

原创 求最大水容器

给定n个非负整数,表示水库隔板的高度,选出两个,求最大的容器面积两个指针,从两头往中间移动,每次移动较小的数值,求最大的积int FindMaxWater(int *IA, int len){ int i=0,j=len-1; int ret = 0; while(i < j) { ret = max(ret, (j-i) * min(IA[i], IA[j])); ...

2021-08-13 13:15:54 106

原创 string转int

自己大致实现的,有点粗糙int Atoi(const string& str){ int ret = 0; bool bFirst = false; bool bMinus = false; for(int i=0; i < str.length(); ++i) { if(str[i] == ' ') continue; if(str[i] ...

2021-08-12 16:01:23 475

原创 int数字反转

例如 1234,反转后变成4321int ReverInt(int x){ bool bFlag = x<0?true:false; if(bFlag) x = -x; long long ret = 0; while(x>0) { int bit = x%10; ret = ret*10 + bit; x /...

2021-08-12 15:18:14 399

原创 每日一算法(查找字符串最大回文字符串)

查找一个字符串里的最大回文字符串1. 使用动态规划方法,把该字符串逆序,相当于查找正序和逆序两个字符串中的最大公共子字符串的长度void FindMaxMid(const string& S){ string _S; _S.resize(S.size()); for(int i=S.length()-1, j=0; i >=0; i--,j++) { _S[j] = S[i]; ...

2021-08-12 13:20:07 400

原创 每日一算法(查找两个数组的中位数)

数组是排序的,总大小知道,可以知道中位数的索引位置,使用两个指针,类似归并排序,到中间位置后停止void FindMid(int *arr1, int len1, int *arr2, int len2){ int p1 = 0; int p2 = 0; int total = len1+len2; int mid1 =0; if(total%2 == 1) { mid1 ...

2021-08-11 13:54:50 175

原创 每日一算法(查找字符串最大长度不重复子串)

//遍历 O(N2)int findMax(const string& strsrc){ int ret = 0; int cTemp[256] = {0}; for(int i=0; i < strsrc.length(); ++i) { int mid_ret = 0; memset(cTemp, 0, sizeof(cTemp)); ...

2021-08-10 13:36:11 129

原创 每日一算法(链表计算和,超过进位)

类似加法计算,进位,用链表存储struct Node{ int value; Node* next; Node() { value = 0; next = NULL; } Node* AddNode(Node* curNode, int iv) { Node* node = new Node(...

2021-08-09 11:04:46 77

原创 每日一算法:数组中查找两位数和为指定值

通过map,往前查找,有没有和当前值和为指定值的int main(){ int testarr[] = {1,2,3,4,5,6,7,8,9,10}; int target = 10; std::map<int, int> testMap; for(int i=0; i < 10; ++i) { int temp = target - testarr[i]; ...

2021-08-09 11:03:25 164

程序员面试宝典

程序员面试宝典,含C,C++,数据库.NET各自面试笔试题,含答案,找工作必看宝典

2014-02-27

python参考手册

python参考手册,详细的python技术使用手册,比较全方面的深度瓦解语法,组织结构层面

2012-09-17

UNIX高级编程

目录 译者序 译者简介 前言 第1章 UNIX基础知识 1 1.1 引言 1 1.2 登录 1 1.2.1 登录名 1 1.2.2 shell 1 1.3 文件和目录 2 1.3.1 文件系统 ...

2011-11-15

深入理解linux内核

这本书太经典了,言语精炼废话不多,信息量大,细节较多。   但不适合做为学习linux内核的第一本书,最好是手头还有一本介绍内核原理的概括一点的书,先看原理,再对照看这本。一章一章对照看。

2011-10-10

SNMP协议分析

SNMP 是为网络管理服务而定义的应用协议,在 1988 年 8 月首次定义,由 Internet 工 程任务组织(Internet Engineering Task Force)(IETF)的研究小组为了解决 Internet 上的路由器管理问题而提出的,很快就在 RFC1157 中达到了正式标准

2011-09-08

AGENT中英文对照译文

AGENT中英文对照译文。Snmp++是为网络管理应用程序开发者提供的具有SNMP服务的一套C++类的集合;Agent++是在Snmp++的基础上,扩展了Snmp++中的概念

2011-09-08

SNMP++中文说明资料

SNMP++中文说明资料. 这是篇描述 SNMP++的文档。面向对象的 SNMP++是一套专注于网络管理的开放技术,是 SNMP 协议原理和 C++结合的产物。该文档描述了各种各样可移植的 C++类(Class),正 是这些 C++类构建了 SNMP++。同时包含的还有这些类的相关的许多例子。 。

2011-09-07

编程珠玑-PDF中文第二版

编程珠玑,主要介绍常用的算法,排序,查找等,数据结构程序以及程序优化,栈,堆,以及时间空间的优化

2011-07-10

aqt710亲测可用

db2工具aqt710 Your registration key(s) for Advanced Query Tool Version 5. are as below. Name: Endy Lambey Key : 6807-4070-8415-1607-6524 You have purchased one upgrade from AQT V6 Standard Edition (or AQT V5) to AQT V6 Extended Edition. The registration details are as follows: Name: Endy Lambey Key: 3930-1666-4148-8229-9499

2011-05-25

空空如也

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

TA关注的人

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