/*
 * Instituto Superior de Engenharia do Porto
 *
 * Estruturas de Informação
 *
 * 2000/2001
 *
 * ------------------------------------------
 *
 * Classe de Vector de Inteiros
 *
 * vectorint.c
 *
 */

#include "vectorint_1.h"
//#include <iostream.h>


VectorInteiros::VectorInteiros(int nCount)
{
	if (nCount <= 0)
	{
		m_count = -1;
		m_vector = NULL;
		return;
	}

	m_count = nCount;
	m_vector = new int[nCount];
}


VectorInteiros::~VectorInteiros()
{
	if (m_vector != NULL)
		delete [] m_vector;
}
	
bool VectorInteiros::escrever(int pos, int valor)
{
	if (pos < 0 || pos >= m_count)
		return false;
	
	m_vector[pos] = valor;
	return true;
}

int VectorInteiros::ler(int pos)
{
	if (pos < 0 || pos >= m_count)
		return 0;
	
	return m_vector[pos];
}

int VectorInteiros::tamanho()
{
	return m_count;
}

