All pastes #838621 Raw Edit

Etwas

public text v1 · immutable
#838621 ·published 2007-12-30 15:07 UTC
rendered paste body

#include <stdlib.h>
#include "resourcematrix.h"

ResourceMatrix::ResourceMatrix()
{
	srand(1);
	
	m_plannedTimeSlicesCount = 100;
	m_resourceCount = 30;
	m_tickResolution = 3;
	
	for (int i = 0; i < m_resourceCount; i++)
	{
		m_resources.append(QVector<int> (m_plannedTimeSlicesCount, 0));
	}
	
	randomize();
}

ResourceMatrix::~ResourceMatrix()
{
}

void ResourceMatrix::randomize()
{
	QMutableVectorIterator< QVector<int> > i(m_resources);
	QVector<int> timeline;
	
	int randomNumber;
	
	while (i.hasNext())
	{
		timeline = i.next();
		
		for (int j = 0; j < timeline.size(); j++)
		{
			randomNumber = rand();
			if (randomNumber  % 2)
			{
				timeline[j] = 1;
			}
		}
	}
}

int ResourceMatrix::resourceCount()
{
	return m_resourceCount;
}

int ResourceMatrix::plannedTimeSclices()
{
	return m_plannedTimeSlicesCount;
}

int ResourceMatrix::tickResolution()
{
	return m_tickResolution;
}

QVector< QVector<int> > ResourceMatrix::getReservations()
{
	return m_resources;
}