// OpenSTA, Static Timing Analyzer
// Copyright (c) 2024, Parallax Software, Inc.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see .
#pragma once
#include
#include
namespace sta {
// Add convenience functions around STL container.
template
class Vector : public std::vector
{
public:
Vector() : std::vector() {}
Vector(size_t n) : std::vector(n) {}
Vector(size_t n, const OBJ &obj) : std::vector(n, obj) {}
// Erase an object from the vector (slow).
void
eraseObject(OBJ obj)
{
auto find_iter = std::find(this->begin(), this->end(), obj);
if (find_iter != this->end())
this->erase(find_iter);
}
void
deleteContents()
{
Iterator iter(this);
while (iter.hasNext())
delete iter.next();
}
void
deleteContentsClear()
{
deleteContents();
this->clear();
}
void
deleteArrayContentsClear()
{
Iterator iter(this);
while (iter.hasNext())
delete [] iter.next();
this->clear();
}
// Java style container itererator
// Vector::Iterator