zoukankan
html css js c++ java
GameStd
/***************************************************************************************************** * File name: GameStd.h * Create time: 2015/03/02 * Module: View * Author: zengqh * Blog: http://blog.csdn.net/aimyton * --------------------------------------------------------------------------------------------------- * Memo: * *****************************************************************************************************/ #ifndef GameStd_h__ #define GameStd_h__ #include <stdlib.h> #include <stdio.h> #include <string.h> #include <math.h> #include <iostream> #include <vector> #include <map> #include <list> #include <deque> #include <queue> #include <set> #include <stack> #include <string> #include <algorithm> #include <functional> /***************************************************************************************************** * Macro and Struct definition *****************************************************************************************************/ /* assert thing */ #define MY_ASSERT(exp) { if (!(exp)) {__asm int 3} } #ifdef _DEBUG #define game_assert MY_ASSERT #else #define game_assert #endif /* safe delete */ #define safe_delete(p) { if((p) != NULL) { delete (p); (p) = NULL; } } #define safe_delete_array(p) { if((p) != NULL) { delete [] (p); (p) = NULL; } } #define safe_release(p) { if((p) != NULL) { (p)->Release(); } } /***************************************************************************************************** * Global variables *****************************************************************************************************/ /***************************************************************************************************** * Global function declare *****************************************************************************************************/ /***************************************************************************************************** * Global function definition *****************************************************************************************************/ inline void* impl_malloc(unsigned int size) { return ::malloc(size); } inline void impl_free(void* ptr) { return ::free(ptr); } /***************************************************************************************************** * Class declare ******************************************************************************************************/ class GameObject { public: virtual ~GameObject() {} void* operator new(unsigned int size) { return impl_malloc(size); } void* operator new(unsigned int size, void* ptr) { size; return ptr; } void operator delete(void* ptr) { impl_free(ptr); } void* operator new[](unsigned int size) { return impl_malloc(size); } void operator delete[](void* ptr) { impl_free(ptr); } void* malloc(unsigned int size) { return impl_malloc(size); } void free(void* ptr) { impl_free(ptr); } }; namespace std { template<class _T> class game_allocator { public: typedef std::size_t size_type; typedef std::ptrdiff_t difference_type; typedef _T* pointer; typedef const _T* const_pointer; typedef _T& reference; typedef const _T& const_reference; typedef _T value_type; template<class _Other> struct rebind { typedef game_allocator<_Other> other; }; game_allocator() { } game_allocator(const game_allocator<_T>&) { } template<class _Y> game_allocator(const game_allocator<_Y>&) { } pointer address(reference _val) const { return (&_val); } const_pointer address(const_reference _val) const { return (&_val); } pointer allocate(size_type _count) { return ((pointer)impl_malloc(_count * sizeof(_T))); } pointer allocate(size_type _count, const void* p) { return allocate(_count); } void deallocate(pointer _ptr, size_type) { impl_free(_ptr); } void construct(pointer _ptr, const _T& _val) { new ((void*)_ptr) _T(_val) } void destroy(pointer _ptr) { _ptr->~_T(); } size_type max_size() const { size_type _n = (size_type)(-1) / sizeof(_T); return (0 < _n ? _n : 1); } bool operator==(const game_allocator<_T>&) const { return true; } }; }; template <class T> class game_vector : public std::vector<T, std::game_allocator<T> > {}; template <class T> class game_list : public std::list<T, std::game_allocator<T> > {}; template <class T> class game_deque : public std::deque<T, std::game_allocator<T> > {}; template <class K, class C = std::less<K> > class game_set : public std::set<K, C, std::game_allocator<K> > {}; template <class K, class T, class C = std::less<K> > class game_map : public std::map<K, T, C, std::game_allocator<T> > {}; template <class T> class game_stack : public std::stack<T, game_deque<T> > {}; template <class T> class game_queue : public std::queue<T, game_deque<T> > {}; template <class T> class game_priority_queue : public std::priority_queue<T, game_vector<T> > {}; typedef std::basic_string<char, std::char_traits<char>, std::game_allocator<char> > game_string; /***************************************************************************************************** * Class definition *****************************************************************************************************/ #endif /* GameStd_h__ */ /***********************************End of File*******************************************************/
查看全文
相关阅读:
C++调用web服务(java事例供参考)
ASP.NET1.1与2.0如何引入MagicAjax (转载自http://hi.baidu.com/zzticzh)
爱,在世界末日时
Why Google Chrome is Multiprocess Architecture
Chrome
Code Reuse in Google Chrome
Google V8 JavaScrit 研究(1)
第一篇文章
User Experience
WPF
原文地址:https://www.cnblogs.com/zengqh/p/2477400.html
最新文章
U盘被写保护无法写入文件的解决办法
SharePoint磁盘容量规划1
SPMetal 默认代码生成规则
TroubleShoot:个人主页上的ActivityFeed WebPart 错误。
Linq to SharePoint中一个列表包含多个Content Type问题
lucene 排序 (Sort SortField 构造函数)
那些年我还不懂:IList,ICollection,IEnumerable,IEnumerator,IQueryable
Entity Framework Func引起的数据库全表查询
Entity Framework 教程
Entity Framework中编辑时错误ObjectStateManager 中已存在具有同一键的对象
热门文章
C#页面前台<%%><%#%><%=%>
lucene中的Token, TokenStream, Tokenizer, Analyzer
ADO.NET Entity Framework 学习(1)
简单正则表达式验证Email地址是否正确
激活已经运行的程序或调用已经启动的程序,并弹出主窗体。
在程序中使用事务,处理无外键关系的表与表间的操作。
SQL关闭自增长列标识:SET IDENTITY_INSERT
方便的选中记录方法(交替项颜色变换):点击DataGrid的一条记录,则选中此记录。
使用游标收缩数据库日志文件并调整数据库属性选项栏部分设置
对IIS、虚拟目录等进行管理
Copyright © 2011-2022 走看看