* Copyright 2007, Haiku Inc. All rights reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
* Stephan Aßmus <superstippi@gmx.de>
*/
#include "PolygonQueue.h"
#include <stdio.h>
#include <string.h>
#include "Polygon.h"
PolygonQueue::PolygonQueue(Polygon* start, int32 depth)
: fPolygons(new Polygon*[depth]),
fDepth(depth)
{
for (int32 i = 0; i < fDepth; i++)
fPolygons[i] = NULL;
fPolygons[fDepth - 1] = start;
}
PolygonQueue::~PolygonQueue()
{
for (int32 i = 0; i < fDepth; i++)
delete fPolygons[i];
delete[] fPolygons;
}
Polygon*
PolygonQueue::Head() const
{
return fPolygons[fDepth - 1];
}
Polygon*
PolygonQueue::Tail() const
{
return fPolygons[0];
}
void
PolygonQueue::Step()
{
if (Polygon* p = Head()) {
Polygon *np = p->Step();
delete Tail();
for (int32 i = 0; i < fDepth - 1; i++)
fPolygons[i] = fPolygons[i + 1];
fPolygons[fDepth - 1] = np;
}
}