- 博客(6)
- 收藏
- 关注
原创 Linux 常用IPC
FIFO又称有名管道,和管道一样,是半双工的,最后一次关闭就丢弃数据。 消息队列:随内核的存在性。存在优先级,一个取,一个拿,链表或者优先队列。...
2018-03-24 11:32:15
222
原创 锁的实现和使用特点
自旋锁:很少的cas指令即可实现,适用于临界区短,尝试锁的时候会占用CPU时间,不会睡眠 mutex:实现较多,会导致睡眠,使用等待队列实现
2018-03-24 09:10:25
154
转载 Splay、treap、avl的实现
以下代码全部来自网络,我只是汇总了一下应对面试(sng腾讯云有问到,没答好)Splay 树typedef struct SplayNode *Tree;typedef int ElementType;struct SplayNode{ Tree parent; //该结点的父节点,方便操作 ElementType val; //结点值 Tree lchild; ...
2018-03-23 17:05:35
678
原创 (最小)堆的实现
int len = 0;vector<int> heap = {0};void init(vector<int> h) { len = 0; h.clear(); h.push_back(0);}void put(int x) { len++; heap.push_back(x); int son = len; while ( son !...
2018-03-23 16:49:45
225
原创 各种基本排序算法
插入排序 稳定void insertion_sort(vector<int> &v) { for (int i = 1; i < v.size(); i++) { int tmp = v[i]; int j = i-1; while (j >= 0 && v[j] > tmp) { v[j+1] = v[...
2018-03-23 16:34:17
214
原创 字符数组中查找给定字符串
这是一位同学的面试题。典型的DFS,唯一和以前不同的是,我改进了move的方法。#include <iostream>#include <string>#include <queue>using namespace std;bool check(const vector<vector<char> > &dict, ...
2018-03-23 14:29:12
3013
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人