Code/Resource
Windows Develop
Linux-Unix program
Internet-Socket-Network
Web Server
Browser Client
Ftp Server
Ftp Client
Browser Plugins
Proxy Server
Email Server
Email Client
WEB Mail
Firewall-Security
Telnet Server
Telnet Client
ICQ-IM-Chat
Search Engine
Sniffer Package capture
Remote Control
xml-soap-webservice
P2P
WEB(ASP,PHP,...)
TCP/IP Stack
SNMP
Grid Computing
SilverLight
DNS
Cluster Service
Network Security
Communication-Mobile
Game Program
Editor
Multimedia program
Graph program
Compiler program
Compress-Decompress algrithms
Crypt_Decrypt algrithms
Mathimatics-Numerical algorithms
MultiLanguage
Disk/Storage
Java Develop
assembly language
Applications
Other systems
Database system
Embeded-SCM Develop
FlashMX/Flex
source in ebook
Delphi VCL
OS Develop
MiddleWare
MPI
MacOS develop
LabView
ELanguage
Software/Tools
E-Books
Artical/Document
StaticArray.h
Package: LegendOfMir2_Server020418.zip [view]
Upload User: szopptop
Upload Date: 2013-04-23
Package Size: 1047k
Code Size: 1k
Category:
Game Server Simulator
Development Platform:
Visual C++
- #pragma once
- template< class T >
- class CStaticArray
- {
- public:
- // 努贰胶 T绰 酒贰 牢磐其捞胶甫 备泅窍咯具 茄促.
- interface IArrayData
- {
- virtual bool IsEmpty() = 0;
- };
- public:
- T * m_pElements;
- int m_nSize;
- int m_nCursor;
- public:
- CStaticArray( int nSize );
- virtual ~CStaticArray();
- int GetFreeKey();
- T & operator []( int nIndex );
- };
- template< class T >
- CStaticArray< T >::CStaticArray( int nSize )
- {
- m_pElements = new T[ nSize ];
- m_nSize = nSize;
- m_nCursor = 0;
- }
- template< class T >
- CStaticArray< T >::~CStaticArray()
- {
- if ( m_pElements )
- delete[] m_pElements;
- }
- template< class T >
- int CStaticArray< T >::GetFreeKey()
- {
- int nFind;
- for ( nFind = m_nCursor; nFind < m_nSize; nFind++ )
- {
- if ( m_pElements[nFind].IsEmpty() )
- {
- m_nCursor++;
- return nFind;
- }
- }
- for ( nFind = 0; nFind < m_nCursor; nFind++ )
- {
- if ( m_pElements[nFind].IsEmpty() )
- {
- m_nCursor++;
- return nFind;
- }
- }
- return -1;
- }
- template< class T >
- T & CStaticArray< T >::operator []( int nIndex )
- {
- return m_pElements[ nIndex ];
- }