mirror of
https://github.com/alliedmodders/hl2sdk.git
synced 2025-09-19 20:16:10 +08:00
Added most recent version of unmodified HL2 SDK for Orange Box engine
This commit is contained in:
69
public/arraystack.h
Normal file
69
public/arraystack.h
Normal file
@ -0,0 +1,69 @@
|
||||
//========= Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
// $Workfile: $
|
||||
// $Date: $
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
// $Log: $
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#ifndef ARRAYSTACK_H
|
||||
#define ARRAYSTACK_H
|
||||
#pragma once
|
||||
|
||||
#include <assert.h>
|
||||
#include "List.h"
|
||||
|
||||
template <class T> class ArrayStack
|
||||
{
|
||||
protected:
|
||||
T *data;
|
||||
int m_stackDepth;
|
||||
int m_maxNumElements;
|
||||
|
||||
public:
|
||||
ArrayStack( int maxNumElements )
|
||||
{
|
||||
data = new T[maxNumElements];
|
||||
m_maxNumElements = maxNumElements;
|
||||
m_stackDepth = 0;
|
||||
assert( data );
|
||||
}
|
||||
|
||||
void Push( T elem )
|
||||
{
|
||||
data[m_stackDepth++] = elem;
|
||||
if( m_stackDepth > m_maxNumElements )
|
||||
{
|
||||
printf( "ArrayStack overflow\n" );
|
||||
assert( 0 );
|
||||
}
|
||||
}
|
||||
|
||||
T Pop( void )
|
||||
{
|
||||
if( m_stackDepth == 0 )
|
||||
{
|
||||
printf( "ArrayStack underflow\n" );
|
||||
assert( 0 );
|
||||
}
|
||||
return data[--m_stackDepth];
|
||||
}
|
||||
|
||||
bool IsEmpty()
|
||||
{
|
||||
return ( m_stackDepth == 0 );
|
||||
}
|
||||
|
||||
int GetDepth()
|
||||
{
|
||||
return m_stackDepth;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
#endif // ARRAYSTACK_H
|
Reference in New Issue
Block a user