노출되는 이미지가 불편하시겠지만 양해를 구합니다. 노출, 클릭등에 관한 자료로 활용 중입니다.

Stack with std::list

#pragma once

#include 
#include 

/*
	Size : Unlimited
	I/O : LIFO, FIFO
*/

template
class NLStack
{
public :
	enum OutType
	{
		LIFO = 0,
		FIFO = 1,
	};
private:
	NLStack()
	{
		Clear();
	}

public:
	NLStack(int out) : m_Out(out)
	{
		Clear();	
	}

	void Clear()
	{
		if ( m_Stack.empty() == false )
		{
			m_Stack.clear();
		}
	}
	int Count() 
	{
		return static_cast( m_Stack.size() ) ;
	}

	bool IsEmpty() 
	{
		return m_Stack.empty();
	}

	// store data 
	void Push( T data )
	{
		m_Stack.push_back( data );
	}
	// extract data
	bool Pop ( T*data )
	{
		if ( IsEmpty() )
			return false;

		switch( m_Out)
		{
		case FIFO:
			//FIFO
			memcpy( data, &m_Stack.front(), sizeof(T) );
			m_Stack.pop_front();
			break;
		case LIFO:
			//LIFO
			memcpy( data, &m_Stack.back(), sizeof(T) );
			m_Stack.pop_back();
			break;
		}
		return true;
	}
	void SetOutType( int out )
	{
		m_Out = out; 
	}

private:
	std::list 	m_Stack;
	int				m_Out;
};



블로그 이미지

StartGuide

I want to share the basic to programming of each category and how to solve the error. This basic instruction can be extended further. And I have been worked in southeast Asia more than 3 years. And I want to have the chance to work another country.

,