~ubuntu-branches/ubuntu/jaunty/aspectc++/jaunty

« back to all changes in this revision

Viewing changes to Puma/src/basics/Array.h

  • Committer: Bazaar Package Importer
  • Author(s): Reinhard Tartler
  • Date: 2008-07-07 14:41:02 UTC
  • mfrom: (1.1.3 upstream) (6.1.1 lenny)
  • Revision ID: james.westby@ubuntu.com-20080707144102-lzml7t07f3sl00r5
Tags: 1.0pre4~svn.20080711-1
* new upstream snapshot.
* include all upstream documentation. Clarifying emails regarding
  licensing has been included into debian/copyright.
* reformat description following recomendations of
  http://www.debian.org/doc/debian-policy/ch-controlfields.html#s-f-Description
  (Closes: #480316)

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
#ifndef __array_h__
20
20
#define __array_h__
21
21
 
 
22
/** \file
 
23
 *  Variable length array implementation. */
 
24
 
22
25
#include <assert.h>
23
26
 
24
27
namespace Puma {
25
28
 
 
29
 
 
30
/** \class Array Array.h Puma/Array.h
 
31
 *  Variable length array implementation. */
26
32
template <class Item>
27
33
class Array {
28
34
protected:
 
35
  /** Default array size. */
29
36
  static const long default_init_size = 5;
 
37
  /** Default array size increment. */
30
38
  static const long default_increment = 5;
31
39
 
32
40
public:
 
41
  /** Constructor.
 
42
   *  \param is The default size of the array. 
 
43
   *  \param incr The default increment value. */
33
44
  Array (long is = default_init_size, long incr = default_increment);
 
45
  /** Copy-constructor.
 
46
   *  \param array The array to copy. */
34
47
  Array (const Array<Item>& array);
35
 
  Array<Item>& operator =(const Array<Item>&);
 
48
  /** Assignment operator.
 
49
   *  \param copy The array to copy. */
 
50
  Array<Item>& operator =(const Array<Item>& copy);
 
51
  /** Destructor. Destroys the array. */
36
52
  ~Array ();
 
53
  /** Append an item to the array. 
 
54
   *  \param item The item to append. */
37
55
  void append (const Item& item);
 
56
  /** Insert an item at the given array index. 
 
57
   *  \param index The array index. 
 
58
   *  \param item The item to insert. */
38
59
  void insert (long index, const Item& item);
 
60
  /** Prepend an item. 
 
61
   *  \param item The item to prepend. */
39
62
  void prepend (const Item& item);
 
63
  /** Remove the array item at the given array index.
 
64
   *  \param index The array index. */
40
65
  void remove (long index);
 
66
  /** Reset the array. Destroys the current array. */
41
67
  void reset ();
 
68
  /** Get a reference to the array item at the given 
 
69
   *  array index. If the index exceeds the array
 
70
   *  bounds, then the array is reallocated accordingly.
 
71
   *  \param index The array index. */
42
72
  Item& get (long index);
 
73
  /** Get a reference to the array item at the given 
 
74
   *  array index. If the index exceeds the array
 
75
   *  bounds, then the array is reallocated accordingly.
 
76
   *  \param index The array index. */
43
77
  Item& operator[] (long index);
 
78
  /** Get the array item at the given array index.
 
79
   *  Does not return a reference, thus the item may
 
80
   *  be implicitely copied. 
 
81
   *  \warning Does not validate the index!
 
82
   *  \param index The array index. */
44
83
  Item fetch (long index) const;
 
84
  /** Get a reference to the array item at the given 
 
85
   *  array index.
 
86
   *  \warning Does not validate the index!
 
87
   *  \param index The array index. */
45
88
  Item& lookup (long index) const;
 
89
  /** Get the number of items in the array. */
46
90
  long length () const;
47
91
 
48
92
private: