Google

TOP --> libjdl

template class CJdlVector

Defines a simple vector container class.

This class does not own its objects.

Here is a simple example that shows how to use this class.

 CJdlVector<int> v;
 for(int i=0;i<10;i++) {
   v[i] = i;
   cout << v[i] << endl;
 }
 // These are all the same.
 cout << v.GetNumItems() << endl;
 cout << v.Size() << endl;
 cout << v.Length() << endl;
 

Author:
Joe Linoff

Version:
$Id: jdlvector.h,v 1.4 1999/06/12 18:26:00 jdl Exp $

Source:
../../libjdl/src/jdlvector.h:46

Constructors Index

CJdlVector
[public] Default constructor.
CJdlVector
[public] Constructor.
CJdlVector
[public] Copy constructor.
~CJdlVector
[public] Destructor.


Methods Index

Append
[public] Append an item to the list.
Append
[public] Append another list to the list.
Clear
[public] Clear the list.
Copy
[public] Copy another list to this one.
Get
[public] Get the i-th item.
GetNumItems
[public] Return the number of items in the list.
Grow
[public] Grow the list to the specified size.
InsertAfter
[public] Insert item after the specified item in the list.
InsertBefore
[public] Insert item before the specified item in the list.
IsEmpty
[public] Is the list empty?
Length
[public] Return the number of items in the list.
MaxLength
[public] Return the maximum number of items that can be stored in the list.
operator +=
[public] Append to the list.
operator =
[public] Copy operator.
operator []
[public] Get the i-th item (lhs & rhs).
Resize
[public] Resize the list.
Set
[public] Set the i-th item. Grow the list if necessary.
Size
[public] Return the number of items in the list.


Constructors

CJdlVector

public CJdlVector ( ) ;

Default constructor.

Assumes a default size of 8.

CJdlVector

public CJdlVector ( uint size ) ;

Constructor.

Parameters:
size The initial size.

CJdlVector

public CJdlVector ( const CJdlVector < T > & obj ) ;

Copy constructor.

Parameters:
obj The object to copy from.

CJdlVector

public ~ CJdlVector ( ) ;

Destructor.


Methods

Clear

public void Clear ( ) ;

Clear the list.

Resize

public void Resize ( uint ) ;

Resize the list.

Parameters:
size Maximum size of the new list.

Copy

public void Copy ( const CJdlVector < T > & ) ;

Copy another list to this one.

GetNumItems

public uint GetNumItems ( ) const ;

Return the number of items in the list.

Return:
The number of items in the list.

Length

public uint Length ( ) const ;

Return the number of items in the list.

Return:
The number of items in the list.

Size

public uint Size ( ) const ;

Return the number of items in the list.

Return:
The number of items in the list.

IsEmpty

public bool IsEmpty ( ) const ;

Is the list empty?

Return:
True if there are 0 items in the list or false otherwise.

MaxLength

public uint MaxLength ( ) const ;

Return the maximum number of items that can be stored in the list.

Return:
The maximum number of items that can be stored in the list.

Append

public void Append ( T & obj ) ;

Append an item to the list.

If the list is not large enough, it is automatically increased to accomodate the new object.

Parameters:
obj The object to append.

Append

public void Append ( const CJdlVector < T > & list ) ;

Append another list to the list.

If the list is not large enough, it is automatically increased to accomodate the new objects.

Parameters:
list The list to append.

InsertBefore

public void InsertBefore ( uint idx ,
                           T & obj ) ;

Insert item before the specified item in the list.

Parameters:
idx The index to insert before.
obj The object to append.

InsertAfter

public void InsertAfter ( uint idx ,
                          T & obj ) ;

Insert item after the specified item in the list.

Parameters:
idx The index to insert before.
obj The object to append.

Get

public T & Get ( uint i ) const ;

Get the i-th item.

An assertion is raised if the index is out of bounds

Parameters:
i The index.

Return:
The i-th object.

operator []

public T & operator [ ] ( uint i ) ;

Get the i-th item (lhs & rhs).

If the array is not large enough it is grown.

Parameters:
i The index.

Return:
The i-th object.

Set

public void Set ( uint i ,
                  T val ) ;

Set the i-th item. Grow the list if necessary.

Parameters:
i The index.

Return:
The i-th object.

operator =

public CJdlVector < T > & operator = ( const CJdlVector < T > & obj ) ;

Copy operator.

Parameters:
obj The object to copy.

Return:
The vector object.

operator +=

public CJdlVector < T > & operator += ( T & val ) ;

Append to the list.

Parameters:
val The value to append.

Return:
The vector object.

Grow

public void Grow ( uint sz ) ;

Grow the list to the specified size.

This is used internally by the append and set methods.

Parameters:
sz The new size.

This documentation was generated automatically by the ccdoc tool (version 0.7a).
Click here to submit a bug report or feature request.

Click here to return to the top of the page.