张嘉锡V

导航

 

2020年6月25日

摘要: 注解 元注解:注解其他注解 @Target:描述注解适用范围 @Retention:需要什么级别保存该注解信息,用于描述注解生命周期(SOURCE < CLASS < RUNTIME ) @Document:说明该注解被包含在Javadoc中 @Inherited:说明子类可以继承父类的该注解 自定 阅读全文
posted @ 2020-06-25 21:09 张嘉锡V 阅读(111) 评论(0) 推荐(0) 编辑
 
摘要: 用于高效存储字符串的数据结构-Trie(字典树) 代码模板 void insert(char s[]) { int p = 0; for(int i = 0; s[i]; i++){ int u = s[i] - 'a'; if(!sons[p][u]) sons[p][u] = ++idx; p 阅读全文
posted @ 2020-06-25 16:08 张嘉锡V 阅读(236) 评论(0) 推荐(0) 编辑
 
摘要: 哈希表 开放寻址法: 找到初位置, 如果该位置已经有元素, 在其下一个位置放置 代码模板 int find(int x) { int t = (x % N + N) % N; while (h[t] != null && h[t] != x) { t ++ ; if (t == N) t = 0; 阅读全文
posted @ 2020-06-25 16:05 张嘉锡V 阅读(118) 评论(0) 推荐(0) 编辑
 
摘要: 堆 模拟思路: 几个基本操作:up and down void down(int u) { int t = u; if(u * 2 <= siz && h[u * 2] < h[t]) t = u * 2; if(u * 2 + 1 <= siz && h[u * 2 + 1] < h[t]) t 阅读全文
posted @ 2020-06-25 15:13 张嘉锡V 阅读(171) 评论(0) 推荐(0) 编辑
 
摘要: 数组模拟队列 代码模板 const int N = 1e6 + 10; int q[N], hh = 0, rr = -1; void push(int x) { q[++rr] = x; } void pop() { ++hh; } void isempty() { return hh <= rr 阅读全文
posted @ 2020-06-25 14:48 张嘉锡V 阅读(165) 评论(0) 推荐(0) 编辑
 
摘要: 数组模拟栈 代码模板 const int N = 1e6 + 10; int st[N], tt = -1; void push(int x) { st[++tt] = x; } void pop() { --tt; } bool isempty() { return tt >= 0; } void 阅读全文
posted @ 2020-06-25 13:54 张嘉锡V 阅读(114) 评论(0) 推荐(0) 编辑
 
摘要: 单链表 两种形式 结构体形式 : 申请新节点太慢 struct List { int data; List *next; } 数组模拟 代码模板 const int N = 1e6 + 10; int e[N], ne[N], head, idx; // 初始化:head存的是头结点下标,用idx分 阅读全文
posted @ 2020-06-25 13:47 张嘉锡V 阅读(168) 评论(0) 推荐(0) 编辑