summaryrefslogtreecommitdiff
path: root/utils/Array.h
blob: 2a5da6a44f22d10e6182f459c824246e5e0a564a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/*
 *	CENA C++ Utilities
 *
 *	by Stephane Chatty
 *
 *	Copyright 1990, 1991, 1992
 *	Laboratoire de Recherche en Informatique (LRI)
 *	Centre d'Etudes de la Navigation Aerienne (CENA)
 *
 *	plain and generic arrays (orginal C version by Michel Beaudouin-Lafon)
 *
 *	$Id$
 *	$CurLog$
 */

#ifndef Array_H_
#define Array_H_

#include "cplus_bugs.h"

typedef void IvlArrayItem;

class IvlArray {

protected:
static	IvlArrayItem*	InvalidCell;
	int 	Length;
	IvlArrayItem**	Data;
	void 	Clean ();

public:
		IvlArray (int size, IvlArrayItem* = 0);
		IvlArray (const IvlArray&);
		~IvlArray ();
	void 	Reset (IvlArrayItem* = 0);
	IvlArrayItem*&	operator [] (int i) const;
	IvlArrayItem**	operator + (int) const;
	IvlArray&	operator = (const IvlArray&);
inline	int	Check (int i) const			{ return (i >= 0 && i < Length); }
inline	int 	GetSize () const			{ return Length; }
	void	Resize (int, IvlArrayItem* = 0);
};

#ifndef CPLUS_BUG19
template <class ITEM> class IvlArrayOf : public IvlArray {
public:
inline		IvlArrayOf (int size, ITEM* value = 0) : IvlArray (size, value)		{}
inline		IvlArrayOf (const IvlArrayOf<ITEM>& a) : IvlArray (a)		{}
inline		~IvlArrayOf ()	{}
inline	void	Reset (ITEM* value = 0)	{ IvlArray::Reset (value); }
inline	void	Resize (int size, ITEM* value = 0)	{ IvlArray::Resize (size, value); }
inline	ITEM*&	operator [] (int i) const		{ return (ITEM*&) ((* (IvlArray*) this)[i]); }
inline	ITEM**	operator + (int i) const		{ return (ITEM**) ((*(IvlArray*) this) + i); }
};
#endif

#endif	/* Array_H_ */