##**问题起源**先看下面很简单的一小段程序。```cpp`#include ```````cpptemplate struct Base { void fun() { std::cout struct Derived : Base{ void gun() { ...
分类:
其他好文 时间:
2014-06-19 06:11:12
阅读次数:
244
#include#include#includeint k,h[110],mark;struct M{ int data; struct M *next;}*head[110];void init(){ int i; for(i = 0; i next = NULL; ...
分类:
其他好文 时间:
2014-06-17 00:58:16
阅读次数:
315
1.PyListObject对象 --> 变长可变对象,可看作vector
typedef struct{
PyObject_VAR_HEAD //其中的ob_size表示实际被使用的内存的数量
PyObject **ob_item;//ob_item为指向元素列表的指针,实际上,Python中的list[0]就是ob_item[0]
int allocated;//当前列表中可容纳的元素的总数
}
PyList_Type 对象 --> PyListObject的类型对象
ty...
分类:
编程语言 时间:
2014-06-16 22:48:55
阅读次数:
300
许多文件系统都是通过generic_file_write()函数来实现文件对象的write方法,即write(库函数)->sys_write()->generic_file_write():
ssize_t generic_file_write(struct file *file, const char __user *buf,
size_t count, loff_t *ppos)...
分类:
其他好文 时间:
2014-06-16 22:47:52
阅读次数:
203
继续校赛前的建图任务,当时只写了DFS遍历,今天把BFS也写了一下。
#include
#include
#include
#include
#include
const int maxe = 10001;
using namespace std;
struct node{
int to,w;
node *next;
}*head[maxe];//he...
分类:
其他好文 时间:
2014-06-16 22:25:20
阅读次数:
286
1.PyDictObject对象 --> C++ STL中的map是基于RB-tree的,搜索时间复杂度是O(logN)
PyDictObject采用了hash表,时间复杂度是O(1)
typedef struct{
Py_ssize_t me_hash; //me_key的hash值,避免每次查询都要重新计算一遍hash值
PyObject *me_key;
PyObject *me_value;
}PyDictEntry;
将(key,value)对称为entry,它可以在3种状态...
分类:
编程语言 时间:
2014-06-16 21:22:45
阅读次数:
272
很经典的题目,而且是标准的线段树增加lazy标志的入门题目。
做了好久线段树,果然是practice makes perfect, 这次很畅快,打完一次性AC了。
标志的线段树函数。
主要是:
更新的时候只更新到需要的节点,然后最后的时候一次性把所以节点都更新完毕。
这也是线段树常用的技术。
#include
const int SIZE = 100005;
struct Node...
分类:
其他好文 时间:
2014-06-16 20:38:39
阅读次数:
182
不是BST,那么搜索两节点的LCA就复杂点了,因为节点是无序的。
下面是两种方法,都写进一个类里面了。
当然需要重复搜索的时候,可以使用线段树及多种方法加速搜索。
#include
#include
using namespace std;
class LCANormalTree
{
struct Node
{
int key;
Node *left, *right;...
分类:
其他好文 时间:
2014-06-16 20:20:04
阅读次数:
234
数组构造二叉树并打印本文地址: http://blog.csdn.net/caroline_wendy数组:构造二叉树, 需要使用两个队列(queue), 保存子节点和父节点, 并进行交换;打印二叉树, 需要使用两个队列(queue), 依次打印父节点和子节点, 并进行交换;二叉树的数据结构:struct BinaryTreeNode {
int m_nValue;
BinaryTreeNod...
分类:
其他好文 时间:
2014-06-16 19:45:17
阅读次数:
373