自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(57)
  • 收藏
  • 关注

原创 C++设计模式系列之三行为型模式

1.Iterator模式Iterator.hpp:#ifndef _ITERATOR_HPP#define _ITERATOR_HPP#include struct Player{ int mPID;};class PlayerManager{ public: PlayerManager() :mBeginIter( &mPlayers

2016-06-25 19:52:25 920

原创 C++设计模式系列之二结构型模式

1.Adapter模式Adapter.hpp:#ifndef _ADAPTER_HPP#define _ADAPTER_HPP//第三方库namespace ThirdPartyNameSpace{ class ThirdPartyClass { public: ThirdPartyClass(){} ~ThirdPartyClass(){}

2016-06-24 21:11:25 2203

原创 C++设计模式系列之一创建型模式

1.简单工厂模式Factory.hpp:#ifndef _FACTORY_HPP_#define _FACTORY_HPP_#include class Product{    public:        virtual ~Product(){}    protected:        Product(){}};class XXProduc

2016-06-21 21:02:21 977

原创 C++下超强内置类型定义

typedef char C8;typedef unsigned char U8;typedef short S16;typedef unsigned short U16;typedef int S32;typedef unsigned int U32;typedef long long S64;typedef unsigned long long U64;typedef con

2016-08-25 22:42:17 867

原创 C++下棋牌游戏高性能洗牌算法

#include #include #include #include #include int GCardSrc[54];void ShuffleCard( int *pDestCard, int PlayerCardCnt, int PlayerCnt ){ assert( nullptr != pDestCard ); assert( PlayerCardCnt *

2016-08-06 12:27:20 3301

原创 C++下利用Command设计模式实现undo和redo

Command.hpp:#ifndef _COMMAND_HPP#define _COMMAND_HPP#include #include #include class Command{public: Command(){} virtual ~Command(){} virtual void Execute() = 0;};class InputC

2016-06-29 11:44:18 3040

原创 C++简单多线程事件驱动同步通知到主线程

#include #include #include #include #include #include typedef int s32;typedef unsigned u32;typedef float f32;class LockObject  {  public:      LockObject()      {

2016-06-18 10:57:48 5421

原创 MSSQL中利用TOP提高IF EXISTS查询语句的性能

--有可能返回一条或多个结果集,其实我们只需要知道是否--有数据即可,这样无形中降低了性能IF EXISTS( SELECT xxx FROM dbo.[Table] WHERE xxx = xxxxxx )BEGIN    --do something.END--利用Top x 关键字 只提取一条出来,且我们不需要查询--出来的数据,有时查询出来的数据可能很大(如字符串,或者加密

2016-06-18 10:03:07 1910

原创 MSSQL中全局变量@@identity与方法scope_identity()的区别

1.@@IDENTITY既然是全局变量(包括但不限于@@identity)那么返回的是最后一次表自增列插入的值有时候数据库中我们需要使用存储过程返回当前操作表的ID如果使用@@identity全局变量显然是不合理的因为数据库执行的是并发操作你不能确定同时在同一个数据库中有其他对表的插入操作且含有自增列,如果这个时候返回很可能出现错误,导致返回的并不是我们当前操作的表的ID而

2016-06-15 21:21:08 3989

原创 C++下适合系统自动流程的棋牌游戏服务器桌子类

//适合自动流程的棋牌游戏桌子类class MyXXTable{public: MyXXTable() { //绑定回调数据 mMyStatus[ eGS_1 ] = MyStatus( &MyXXTable::OnStatus1, eGS_2, 2000 ); mMyStatus[ eGS_2 ] = MyStatus( &MyXXTable::OnStatus2, eG

2016-06-14 20:33:32 3314

原创 C++高级排序算法详解

#include #include #include #define XT( str ) #str #define CNT_ARY( ary ) ( sizeof( ary ) / sizeof( ary[ 0 ] ) ) typedef int s32; typedef unsig

2016-06-12 21:11:03 1346

原创 C++基本排序算法详解

#include #include #include #define XT( str ) #str #define CNT_ARY( ary ) ( sizeof( ary ) / sizeof( ary[ 0 ] ) ) typedef int s32; typedef unsigned int u32; //[注意下面都是以降序排序进行说明] //1

2016-06-11 16:39:20 697

原创 C++实现多线程全局内存池(性能优化)

#include #include #include #include #include #include #include #include #include #include typedef int s32;typedef unsigned int u32;typedef char c8;typedef long long s64;typedef unsigned

2016-06-08 20:48:56 4107

原创 C++实现多线程全局内存池

1.内存池数据结构示意图:2.下面是完整实现代码包括与常规new,delete分配内存性能对比:#include #include #include #include #include #include #include typedef int s32;typedef unsigned int u32;typedef char c8;typed

2016-06-07 23:44:23 3617 2

原创 C++实现多线程对象内存池带垃圾回收机制

#include #include #include #include #include #include #include #include typedef int s32;typedef unsigned int u32;typedef char c8;//////////////////////////////////////////////////////////

2016-06-03 21:43:50 2821

原创 C#使用SevenZipSharp库时如何去掉压缩文件中的目录文件夹

using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace ConsoleApplication1{ class Program { static void Main(string[] args) {

2016-06-02 22:20:34 4299

原创 C#实现http多线程断点续传下载文件

using System;using System.Collections.Generic;using System.IO;using System.Threading;using System.Net;using u8 = System.Byte;using u16 = System.UInt16;using s32 = System.Int32;using u32 = Syst

2016-05-31 22:21:05 3481

原创 C#实现http多线程下载文件

using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Threading;using System.IO;using System.Net;using u32 = System.UInt32;using s32 = System.Int32;us

2016-05-30 23:49:22 8528

原创 C++基本数据类型简便定义

// Test.cpp : 定义控制台应用程序的入口点。//#include "stdafx.h"typedef char            c8;typedef unsigned char    u8;typedef short            s16;typedef unsigned short    u16;typedef int        

2016-04-27 22:22:23 878

原创 C++经典面试算法题

#include #include #include ////////////////////////////////////////////////////////////////////////// // C++ 经典面试算法题 [7/28/2016 FreeAngel] //1.实现strcpy. char* MyStrCpy( char *pDest, const

2016-03-01 10:58:38 11683 2

原创 C++下如何更好的定义结构体

int main(){ //如何更好的使用结构体 //例如RPG游戏中通常角色定义如下: struct Character { //基本数据 INT mCharID; INT mLevel; CHAR mName[ 32 ]; INT mExp; INT mJob; //货币 INT mCopper; INT mIngot; //属性点

2016-01-22 11:44:57 719

原创 C++下如何避免方法的方式并且安全的访问类的成员变量

#include class Test{public:    Test()        :mData( 0 )        ,mDataRef( mData )    {}    ~Test()    {}    void DoSomething()    {        ++mData;    }private:

2015-12-18 11:58:56 674

原创 C++Windows下SQLite简单封装

SQLiteCommand.h:#pragma once#include  #include  #include  #include "sqlite3.h"class SQLiteCommand{    public:        SQLiteCommand();        ~SQLiteCommand();        bool Connect(

2015-12-10 23:58:01 1538

原创 C++如何将N维数组作为参数动态传给方法

#include "stdafx.h"//直接特例化模板参数templatevoid PrintArray( int pArray[ N ][ M ] ){ for( int i = 0; i < N; ++i ) { for( int j = 0; j < M; ++j ) { printf( "%d", pArray[ i ][ j ] ); } prin

2015-11-17 19:10:13 1439

原创 C++位域详解

#include int main(){ //1.位域允许我们使用内存最小单位BIT位来存储数据,某些情况下可以为我们节省内存 //2.位域是以数据类型来区分区域的,几种数据类型就表示有几个位域段( 未指定占用位,除外 ) //3.同种位域类使用BIT位超过该位域数据类型大小自动完后继续占用该位域数据类型大小 //4.未用完的BIT位还是要占用内存空间的即不存在只使用int类型的其中4

2015-10-21 17:08:48 4431

原创 C++Windows下如何让窗口进程只运行一个实例

为了方便我们新建一个名为MFCTest的MFC对话框项目然后打开找到CMFCTestApp::InitInstance()函数添加单实例检测代码:BOOL CMFCTestApp::InitInstance(){ ////////////////////////////////////////////////////////////////////////// //单实例检测 tr

2015-10-20 11:46:16 3084 1

原创 C++Windows下CONTAINING_RECORD宏的用法和详解

#include #include int main(){ struct ABCD { int a; int b; int c; int d; }; //CONTAINING_RECORD宏的作用就是根据结构体 //类型和结构体中成员变量地址和名称则可求出 //该变量所在结构体的指针 ABCD Abcd = { 1, 2, 3, 4 }; //假设我们知道AB

2015-10-20 10:44:52 5267

原创 C++Windows下递归遍历多级目录

#include #include #include #pragma comment( lib, "Shlwapi.lib" )#include bool ForeachFileByDirectory( LPCTSTR pDirectory ){    if( NULL == pDirectory )    {        return false;

2015-10-19 17:15:34 2313

原创 C++Windows下创建多级目录

#include #include #include #pragma comment( lib, "Shlwapi.lib" )#include bool CreateMultipleDirectory( LPCTSTR pDirectory ){ if( NULL == pDirectory ) { return false; } //目录或文件已存在 if( Path

2015-10-19 15:40:58 3893

原创 C++对象池完整实现

ObjectPool.hpp:#pragma once#include #include #include #include #ifndef nullptr#define nullptr 0#endiftemplateclass ObjectPool{ public: //初始化块大小如果能预先估算出块大小则性能达到最大 //即:只分配一次内存只释放一次内存

2015-10-16 10:38:50 5635

原创 Lua栈操作详解

1.让我们看看下面例子C++调用LUA函数的例子栈的使用情况#include "stdafx.h"int main(){ //新建一个lua状态 lua_State *pLua = luaL_newstate(); if( nullptr == pLua ) { return 0; } //得到初始化栈大小 printf( "初始化栈大小:%d\n", lua_gett

2015-10-15 15:04:28 4559

原创 WIN7+VS2008+C++下7zipSDK压缩解压缩的使用

1.官方最新版下载地址http://www.7-zip.org/sdk.html下载下来的文件如图:打开下面这个目录:打开VS2008命令工具:将命令行指定到刚才的目录中并输入nmake进行编译中:如果出现/OPT:NOWIN98 链接错误 输入nmake NEW_COMPILER=1 MY_STATIC_LINK=1 重新编

2015-10-13 11:31:58 7689 1

原创 C++如何避免使用rand() % xxx的方式实现类似抽奖概率类的问题

头文件:#pragma once#include #include class Weight{ public: template static int GetWeightIndex( const T *pSrcWeight, size_t Size ) { if( 0 == pSrcWeight || 0 == Size ) { return ~0;

2015-09-28 11:39:36 4164 1

原创 C++多线程定时器完整实现

头文件:#pragma once#include #include #include //回调接口typedef struct ITimerEngineCallBack{ virtual bool OnTimerEngineCallBack( DWORD TimerID, DWORD Param ) = 0;}* ITimerEngineCallBackPtr;clas

2015-09-23 12:30:19 13262 1

原创 C++多线程Singleton模式

#include #include //锁class LockObject{ public: LockObject() { InitializeCriticalSection( &mLock ); } virtual ~LockObject() { DeleteCriticalSection( &mLock ); } void Lock()

2015-09-22 15:29:13 916

原创 boost::lexical_cast简单实现

#include templateOutput custom_cast( const Input &In ){ std::stringstream Converter; //关键核心使用字符流 Converter << In; //读取输入 Output Out; Converter >> Out; //写入到输出 return Out;}int main(){

2015-09-22 11:27:17 744

原创 C++ 联合体共享变量值的计算

输入下面代码: #include union stTest { int a; char b[2]; }; int main() { stTest t; t.a = 300; printf( "%u %

2015-09-17 11:32:36 1238

原创 C++ 结构体字节对齐

1.字节对齐的作用加快CPU访问内存速度,平台移植2.如何计算字节对齐后的结构体大小输入下面代码:#include struct stTest{ int a; char b; short c;};int main(){ printf( "%u\n", sizeof( stTest ) ); return 0;}输出结果为8.字节对齐有

2015-09-02 15:03:14 1082

原创 如何在圆内随机点坐标

#include #include #include using namespace std;int main(){ //思路就是围绕这个坐标为圆心,产生不同半径的圆,然后在取这个圆上,不同角度或方向的点即可 typedef struct tagPoint { float x; float y; } Point; //圆心坐标 const Point CycPoin

2014-10-24 15:45:25 8945 4

原创 C++如何导出DLL

1.导出全局函数2.导出

2014-09-06 11:47:10 2309

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除