摘要: iface.go package GabrielConfig import ( "context" "sync" ) type IGracefulExit interface { Cancel() GetCtx() context.Context GetWaitGroupInCtx() *sync. 阅读全文
posted @ 2020-12-30 16:32 路璐 阅读(856) 评论(0) 推荐(0) 编辑
摘要: package main import ( "errors" "math/rand" ) type CompareResult int // TODO 目前尚未实现并发安全,待办 const ( // 跳表节点key的比较回调函数返回值 -1:left<right;0:left==right;1:l 阅读全文
posted @ 2020-12-30 15:54 路璐 阅读(177) 评论(0) 推荐(0) 编辑
摘要: 代码如下: 1 package main 2 3 import ( 4 "fmt" 5 "regexp" 6 ) 7 8 // 判断str是否与白名单中的正则表达式匹配 9 func generateMatch(whiteList []string) func(string) bool { 10 / 阅读全文
posted @ 2020-11-10 16:03 路璐 阅读(525) 评论(0) 推荐(0) 编辑
摘要: 代码如下: 1 package main 2 3 import ( 4 "fmt" 5 ) 6 7 func pivot(arr []int, begin int, end int) int { 8 end-- 9 temp := arr[begin] 10 // 为减小最坏情况发生的几率,可以在b 阅读全文
posted @ 2020-11-10 10:10 路璐 阅读(456) 评论(0) 推荐(0) 编辑
摘要: 服务端 /* * main.c * 测试udp Socket套接字 单任务服务端代码实现 * Created on: 2020年3月4日 * Author: LuYonglei */ #include <sys/socket.h> #include <arpa/inet.h> #include <u 阅读全文
posted @ 2020-03-04 13:25 路璐 阅读(430) 评论(0) 推荐(0) 编辑
摘要: typedef union bigSmallEnd{ unsigned short a; unsigned char b[2]; }BSE; void testBSE() { BSE test; test.a = 0x0102; if (test.b[0] == (unsigned char) 0x 阅读全文
posted @ 2020-03-04 10:32 路璐 阅读(271) 评论(0) 推荐(0) 编辑
摘要: /* * main.c * 子进程状态改变会发送SIGCHLD信号给父进程 * 此处实现父进程创建并回收多个子进程 * Created on: 2020年3月3日 * Author: LuYonglei */ #include <stdlib.h> #include <stdio.h> #inclu 阅读全文
posted @ 2020-03-03 18:58 路璐 阅读(1584) 评论(0) 推荐(0) 编辑
摘要: 非优化版本 /* * NQueens.h * * Created on: 2020年3月2日 * Author: LuYonglei */ #ifndef SRC_NQUEENS_H_ #define SRC_NQUEENS_H_ #include <iostream> using namespac 阅读全文
posted @ 2020-03-02 17:53 路璐 阅读(673) 评论(0) 推荐(0) 编辑
摘要: 头文件 /* * MemoryManage.h * * Created on: 2020年2月22日 * Author: LuYonglei */ #ifndef SRC_MEMORYMANAGE_H_ #define SRC_MEMORYMANAGE_H_ #include <stdlib.h> 阅读全文
posted @ 2020-03-02 17:50 路璐 阅读(441) 评论(0) 推荐(0) 编辑
摘要: /* * UnionFind.h * 有两种实现方式,QuickFind和QuickUnion * QuickFind: * 查找O(1) * 合并O(n) * QuickUnion:(建议使用) * 查找O(logn)可优化至O(a(n)),a(n)<5 * 合并O(logn)可优化至O(a(n) 阅读全文
posted @ 2020-02-28 15:47 路璐 阅读(300) 评论(0) 推荐(0) 编辑