C++
bin_4545
这个作者很懒,什么都没留下…
展开
-
huffman 树
#include#include#include#include#include#define MAX_NUM 100#define inf 2000000000using namespace std;typedef struct { unsigned int weight;//权值 unsigned int parent,lchild,rchild;//父节点,孩子结点的权原创 2016-12-20 14:54:06 · 148 阅读 · 0 评论 -
C++动态内存管理
一、malloc/free和new/delete的联系和区别。一).malloc/free1.函数原型及说明: void* malloc(long NumBytes):该函数分配了NumBytes个字节,并返回指向这块内存的指针。如果分配失败,则返回一个空指针(NULL)。void free(void *FirstByte):该函数是将之前用malloc分配原创 2017-07-25 17:54:57 · 132 阅读 · 0 评论 -
map和set增删查改
1.增添元素(1)insert增加元素的四种形式numCountMap.insert({numName,thisAddTime});numCountMap.insert(make_pair(numName,thisAddTime));numCountMap.insert(pairint,int>(numName,thisAddTime));numCountMap.insert(m原创 2017-11-12 22:44:33 · 203 阅读 · 0 评论 -
关于智能指针!
智能指针的发展史:先从RAII说起: RAII(Resource Acquisition Is Initialization)资源分配即初始化,定义一个类来封装资源的分配和释放,在构造函数完成资源的分配和初始化,在析构函数完成资源的清理,可以保证资源的正确初始化和释放。auto_ptr:实际上,为了正确地管理资源,人们进行了包括但不仅限于flag原创 2017-11-05 11:16:33 · 162 阅读 · 0 评论 -
Vector和List
Vector和List的区别:1.vector数据结构vector和数组类似,拥有一段连续的内存空间,并且起始地址不变。因此能高效的进行随机存取,时间复杂度为o(1);但因为内存空间是连续的,所以在进行插入和删除操作时,会造成内存块的拷贝,时间复杂度为o(n)。另外,当数组中内存空间不够时,会重新申请一块内存空间并进行内存拷贝。2.list数据结构list是由双向链表实原创 2017-11-05 11:35:18 · 218 阅读 · 0 评论