source: tol/toltcl/generic/tt_pool.h @ fe54d8d

1941-docker-image-to-testdevel
Last change on this file since fe54d8d was 6d7779d, checked in by Jorge Pérez <josp.jorge@…>, 18 years ago

initial import

git-svn-id: ​https://www.tol-project.org/svn/tolp/trunk@1 be4846ae-f051-483a-831f-b64e7d08527f

  • Property mode set to 100644
File size: 1.6 KB
Line 
1/* tt_pool.h - This file implements a simple pool of objects.
2               GNU/tolTcl Library
3
4   Copyright (C) 2001, 2002, 2003 - Bayes Decisión, SL
5
6   This program is free software; you can redistribute it and/or modify
7   it under the terms of the GNU General Public License as published by
8   the Free Software Foundation; either version 2, or (at your option)
9   any later version.
10
11   This program is distributed in the hope that it will be useful,
12   but WITHOUT ANY WARRANTY; without even the implied warranty of
13   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14   GNU General Public License for more details.
15
16   You should have received a copy of the GNU General Public License
17   along with this program; if not, write to the Free Software
18   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
19   USA.
20 */
21
22#ifndef TT_POOL_H
23#define TT_POOL_H 1
24
25#include <tt_common.h>
26
27class ToltclPool {
28public:
29  ToltclPool( int ini = 10, int grow = 5 );
30  ToltclPool( const ToltclPool & pool );
31  ~ToltclPool();
32  int AppendObject( void * ptr );
33  void PrependObject( void * ptr );
34  void ** GetObject( int i ) {
35    if ( CheckIndex( i ) )
36      return _GetObject(i);
37    return NULL;
38  }
39  void ** _GetObject( int i ) {
40    return m_pool+i;
41  }
42  void * RemoveObject( int i ) {
43    if ( CheckIndex( i ) )
44      return _RemoveObject(i);
45    return NULL;
46  }
47  void * _RemoveObject( int i );
48  void * RemoveLast();
49  int GetSize() {
50    return m_last+1;
51  }
52  int GetLast() {
53    return m_last;
54  }
55private:
56  int CheckIndex( int i ) {
57    return i >= 0 && i <= m_size;
58  }
59  int m_last, m_grow, m_size;
60  void ** m_pool;
61};
62
63#endif /* TT_POOL_H */
Note: See TracBrowser for help on using the repository browser.