| 1 |
/* Copyright (C) 1992-1998 The Geometry Center |
| 2 |
* Copyright (C) 1998-2000 Stuart Levy, Tamara Munzner, Mark Phillips |
| 3 |
* |
| 4 |
* This file is part of Geomview. |
| 5 |
* |
| 6 |
* Geomview is free software; you can redistribute it and/or modify it |
| 7 |
* under the terms of the GNU Lesser General Public License as published |
| 8 |
* by the Free Software Foundation; either version 2, or (at your option) |
| 9 |
* any later version. |
| 10 |
* |
| 11 |
* Geomview is distributed in the hope that it will be useful, but |
| 12 |
* WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 14 |
* Lesser General Public License for more details. |
| 15 |
* |
| 16 |
* You should have received a copy of the GNU Lesser General Public |
| 17 |
* License along with Geomview; see the file COPYING. If not, write |
| 18 |
* to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, |
| 19 |
* USA, or visit http://www.gnu.org. |
| 20 |
*/ |
| 21 |
#ifndef _QV_PLIST_ |
| 22 |
#define _QV_PLIST_ |
| 23 |
|
| 24 |
#include <QvBasic.h> |
| 25 |
|
| 26 |
class QvPList { |
| 27 |
public: |
| 28 |
QvPList(); |
| 29 |
~QvPList(); |
| 30 |
void append(void * ptr) |
| 31 |
{ if (nPtrs + 1 > ptrsSize) expand(nPtrs + 1); |
| 32 |
ptrs[nPtrs++] = ptr; } |
| 33 |
int find(const void *ptr) const; |
| 34 |
void remove(int which); |
| 35 |
int getLength() const { return (int) nPtrs; } |
| 36 |
void truncate(int start) |
| 37 |
{ nPtrs = start; } |
| 38 |
void *& operator [](int i) const { return ptrs[i]; } |
| 39 |
|
| 40 |
private: |
| 41 |
void ** ptrs; |
| 42 |
int nPtrs; |
| 43 |
int ptrsSize; |
| 44 |
void setSize(int size) |
| 45 |
{ if (size > ptrsSize) expand(size); nPtrs = size; } |
| 46 |
void expand(int size); |
| 47 |
}; |
| 48 |
|
| 49 |
#endif /* _QV_PLIST_ */ |