/* * Copyright 2010, Haiku. All rights reserved. * Distributed under the terms of the MIT License. * * Authors: * Michael Pfeiffer */ #include template GPArray::GPArray() : fArray(NULL), fSize(0) { } template GPArray::~GPArray() { if (fArray != NULL) { for (int i = 0; i < fSize; i ++) delete fArray[i]; delete[] fArray; fArray = NULL; } } template void GPArray::SetSize(int size) { ASSERT(fSize == 0); fArray = new PointerType[size]; if (fArray == NULL) return; fSize = size; for (int i = 0; i < size; i ++) { fArray[i] = NULL; } } template int GPArray::Size() const { return fSize; } template void GPArray::DecreaseSize() { ASSERT(fArray != NULL); ASSERT(fArray[fSize-1] == NULL); fSize --; } template TYPE** GPArray::Array() { return fArray; } template TYPE ** GPArray::Array() const { return fArray; } template bool GPArray::IsEmpty() const { return fSize == 0; }