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*******************************************************/
查看全文
相关阅读:
Java里的堆(heap)栈(stack)和方法区(method)
SpringMVC 的 Controller 返回各种视图的处理方式
Nginx Open File Cache
HandlerInterceptor与MethodInterceptor
Mysql的with rollup分组统计功能(5.1以上版本)
idea中@data不生效
java中? extends T 和? super T解析
java8排序
spring boot gateway自定义限流
spring boot添加logging不能启动且不报错
原文地址:https://www.cnblogs.com/zengqh/p/2477400.html
最新文章
查看MSSQL数据库每个表占用的空间大小
基于NodeJS的14款Web框架
Force SDK to create Appointment programmatically in crm 2013 onPremise
关于setTimeout()你所不知道的地方
NPM设置代理
php排序算法及二分法查找
sed和awk用法
记录一次elasticsearch-php工作过程
Python中让MySQL查询结果返回字典类型的方法
Django使用静态文件
热门文章
使用Tensorflow训练自己的数据
推荐算法学习
Tensorflow Object Detection API 安装
Object Detection API 相关
node.js cheerio API
BeanPostProcessor接口
spring面试题
Spring Boot 配置优先级顺序
Logback学习笔记
Spring发送基于freemarker模板的邮件
Copyright © 2011-2022 走看看