<commit_before>/*
 * copyright: (c) RDO-Team, 2010
 * filename : rdoindexedstack.h
 * author   :  
 * date     : 23.02.2010
 * bref     : 
 * indent   : 4T
 */

#ifndef _RDOINDEXEDSTACK_H_
#define _RDOINDEXEDSTACK_H_

// ====================================================================== INCLUDES
#include <map>
// ====================================================================== SYNOPSIS
#include "rdo_common/namespace.h"
#include "rdo_common/rdomacros.h"
#include "rdo_common/rdotypes.h"
#include "rdo_common/rdoidgenerator.h"
// ===============================================================================

OPEN_RDO_NAMESPACE

template<class T>
class IndexedStack
{
public:
	typedef IDGenerator::ID ID;

	IndexedStack()
	{}

	ID push(CREF(T) object)
	{
		std::pair<Stack::iterator, rbool> result = m_stack.insert(
			std::pair<Stack::key_type, Stack::mapped_type>(m_generator.get(), object)
		);
		ASSERT(result.second);
		return result.first->first;
	}
	T pop(ID index)
	{
		Stack::iterator it = m_stack.find(index);
		ASSERT(it != m_stack.end());
		T object = it->second;
		m_stack.erase(it);
		return object;
	}

private:
	typedef std::map<IDGenerator::ID, T> Stack;
	Stack       m_stack;
	IDGenerator m_generator;
};

CLOSE_RDO_NAMESPACE

#endif //! _RDOINDEXEDSTACK_H_
<commit_msg> - понижена защищенность для наследников<commit_after>/*
 * copyright: (c) RDO-Team, 2010
 * filename : rdoindexedstack.h
 * author   :  
 * date     : 23.02.2010
 * bref     : 
 * indent   : 4T
 */

#ifndef _RDOINDEXEDSTACK_H_
#define _RDOINDEXEDSTACK_H_

// ====================================================================== INCLUDES
#include <map>
// ====================================================================== SYNOPSIS
#include "rdo_common/namespace.h"
#include "rdo_common/rdomacros.h"
#include "rdo_common/rdotypes.h"
#include "rdo_common/rdoidgenerator.h"
// ===============================================================================

OPEN_RDO_NAMESPACE

template<class T>
class IndexedStack
{
public:
	typedef IDGenerator::ID ID;

	IndexedStack()
	{}

	ID push(CREF(T) object)
	{
		std::pair<Stack::iterator, rbool> result = m_stack.insert(
			std::pair<Stack::key_type, Stack::mapped_type>(m_generator.get(), object)
		);
		ASSERT(result.second);
		return result.first->first;
	}
	T pop(ID index)
	{
		Stack::iterator it = m_stack.find(index);
		ASSERT(it != m_stack.end());
		T object = it->second;
		m_stack.erase(it);
		return object;
	}

protected:
	typedef std::map<IDGenerator::ID, T> Stack;
	Stack       m_stack;
	IDGenerator m_generator;
};

CLOSE_RDO_NAMESPACE

#endif //! _RDOINDEXEDSTACK_H_

{'fraction_non_alphanumeric': 0.27173517642779194, 'fraction_numerical': 0.009457984721716987, 'mean_word_length': 4.064456721915286, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1454463', 'n_tokens_mistral': 1021, 'n_tokens_neox': 924, 'n_words': 160}