Implement strStr().Returns a pointer to the first occurrence of needle in haystack, ornullif needle is not part of haystack.方法一:暴力破解,O(mn),超时,写了这段代码,估...
分类:
其他好文 时间:
2014-09-07 22:25:45
阅读次数:
328
Implement strStr().Returns a pointer to the first occurrence of needle in haystack, or null if needle is not part of haystack.思路:使用DFS即可。 1 class Solu...
分类:
其他好文 时间:
2014-09-06 12:10:03
阅读次数:
199
智能指针(smart pointer)是存储指向动态分配(堆)对象指针的类,用于生存期控制,能够确保自动正确的销毁动态分配的对象,防止内存泄露。它的一种通用实现技术是使用引用计数(reference count)。智能指针类将一个计数器与类指向的对象相关联,引用计数跟踪该类有多少个对象共享同一指针。...
分类:
编程语言 时间:
2014-09-06 10:53:53
阅读次数:
374
智能指针(smart pointer)是存储指向动态分配(堆)对象指针的类,能够在适当的时间自动删除指向的对象外,能够确保正确的销毁动态分配的对象。
标准库的智能指针为auto_ptr。boost库的智能指针族在功能上做了扩展。
1.auto_ptr
auto_ptr注意事项如下。
①auto_ptr不能共享所有权。
②auto_ptr不能指向数组。
③auto_ptr不能作为...
分类:
编程语言 时间:
2014-09-05 16:18:21
阅读次数:
204
A linked list is given such that each node contains an additional random pointer which could point to any node in the list or null.
Return a deep copy of the list.
/**
* Definition for singly-lin...
分类:
其他好文 时间:
2014-09-04 19:12:40
阅读次数:
201
HighLight:1. Pointer 1). 用法 2). 指针参数 3). 野指针 4). 指针返回值 5). 指针加减整数 6). 数组和指针 7). const指针和指针const2. StringPointer1. Basic 多字节的数据,将其首字节地...
分类:
其他好文 时间:
2014-09-04 18:52:49
阅读次数:
151
1、头文件
#include "cocos2d.h"
USING_NS_CC;
class MenuItemDemo : public cocos2d::Layer
{
public:
// there's no 'id' in cpp, so we recommend returning the class instance pointer
static cocos2d::S...
分类:
其他好文 时间:
2014-09-04 00:16:17
阅读次数:
232
ie6-ie8浏览器不支持这个属性.fixed{ position:fixed; /*对于火狐等其他浏览器需要设置的*/ top:700px; /*同上*/ width:30px; height:30px; cursor:pointer; display:none; } .ie{ _p...
分类:
其他好文 时间:
2014-09-03 16:15:46
阅读次数:
243
第三章:迭代器概念与traits编程技法 迭代器是一种smart pointer auto_Ptr 是一个用来包装原生指针(native pointer)的对象,声明狼藉的内存泄漏问题可藉此获得解决。 auto_ptr用法如下,和原生指针一模一样:void func() { auto_p...
分类:
其他好文 时间:
2014-09-02 22:34:25
阅读次数:
266