单例模式确保某一个类只有一个实例,而且自行实例化并向整个系统提供这个实例。这里主要介绍下在arc下,利用gcd实现单例。第一步:声明一个静态实例staticSoundTool
*_instance;第二步:重写初始化方法+ (id)allocWithZone:(struct _NSZone *)zo...
分类:
移动开发 时间:
2014-05-29 02:49:34
阅读次数:
367
1、初始化一个UITableView1 -
(id)initWithFrame:(CGRect)frame style:(UITableViewStyle)style1 struct CGRect {2
CGPoint origin;3 CGSize size;4 };5 typedef...
分类:
其他好文 时间:
2014-05-29 02:42:20
阅读次数:
254
题目链接说来算是个基础题目,可是还是各种CE,各种WA,基础还是不扎实。附上代码: 1 /** 2 *
Definition for singly-linked list. 3 * struct ListNode { 4 * int val; 5 *
ListNode *ne...
分类:
其他好文 时间:
2014-05-28 23:56:38
阅读次数:
382
刚才学了gethostbyname函数,这个gethostbyaddr函数的作用是通过一个IPv4的地址来获取主机信息,并放在hostent结构体中。#include
struct hostent * gethostbyaddr(const char * addr, socklen_t len,.....
分类:
其他好文 时间:
2014-05-28 01:46:42
阅读次数:
331
#include #include #include #include #include
#include #define MAXLINE 80 #define SERV_PORT 6970 void do_echo(int sockfd,
struct sockaddr *pcl...
分类:
系统相关 时间:
2014-05-27 18:06:51
阅读次数:
435
引子
前些时候,我在群里出了一道题目:将变参的类型连接在一起作为字符串并返回出来,要求只用函数实现,不能借助于结构体实现。用结构体来实现比较简单:template
struct Connect;templatestruct Connect{ static string GetName() ...
分类:
编程语言 时间:
2014-05-27 16:25:51
阅读次数:
492
C++中有以下几种自定义数据类型方式:typedef、union、enumtypedeftypedef只是用于重命名一种已有的数据类型。typedef
char C; //C c即char c typedef char field [50]; //field...
分类:
编程语言 时间:
2014-05-26 20:20:40
阅读次数:
235
类模板:template struct
pair参数:T1是第一个值的数据类型,T2是第二个值的数据类型。功能:pair将一对值组合成一个值,这一对值可以具有不同的数据类型(T1和T2),两个值可以分别用pair的两个公有函数first和second访问。具体用法:1.定义(构造):1
p...
分类:
编程语言 时间:
2014-05-26 17:54:31
阅读次数:
327
1001
暴力
#include
#include
#include
using namespace std;
const int maxn = 100100;
int ll[maxn], rr[maxn];
struct node
{
int x, y, bj;
}e[maxn];
int main()
{
int cas = 1;
int T;
scanf("%d...
分类:
其他好文 时间:
2014-05-25 21:32:50
阅读次数:
268
最近写了一个接受socket数据包,然后再重组上层协议包的东西。每次read到数据就将数据添加到一个链表的尾部,然后检查是否收到了一个完整的包。为了减少内存碎片,把用过的链表节点添加到另外一个链表中,这样下次可以从这个cache链表中重用节点。
在debug的时候我把cache list中的数据打印出来,代码如下:
struct seg_node
{
void* bu...
分类:
其他好文 时间:
2014-05-25 21:31:09
阅读次数:
326