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*******************************************************/
查看全文
相关阅读:
Hadoop集群VSFTP和SecureCRT安装配置
Hadoop集群完全分布式坏境搭建
Hadoop集群坏境搭建配置
Hadoop集群坏境CentOS安装
Pr视频剪辑基础技巧学习
SAN和NAS之间的基本区别
原始容量、可用容量和有效容量的区别
解释一下什么是网盘与云盘
纠错技术之FEC(向前纠错)
分布式存储的冗余类型(N+2:1)
原文地址:https://www.cnblogs.com/zengqh/p/2477400.html
最新文章
高效会议引导之回顾会会议
深入探索RB-tree数据结构
Linux Kernel Oops异常分析
自动提交Git branch代码评审到Review Board系统
团队Git工作流总结
2015年读书总结
Highcharts——大气好用的图标制作工具
关于sql server远程访问Oracle数据库 OpenQuery查询返回多条数据的问题
ORACLE 创建作业JOB例子
sql server远程访问Oracle数据库
热门文章
如何实现Oracle修改用户权限 .
oracle行列转换函数的使用
SQL行转列汇总
select into from 和 insert into select 的用法和区别
sql server日期时间转字符串
JAVA API操作-创建目录
登录注册界面模板
修改/etc/profile文件出错,找不到命令
【Linux】CentOS7下安装JDK详细过程
Hadoop集群MYSQL的安装
Copyright © 2011-2022 走看看