Main Page | Modules | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

BasicDataStructures::List< list_type > Class Template Reference

#include <ArrayList.h>

List of all members.

Public Member Functions

 List ()
 ~List ()
 List (const List &original_copy)
Listoperator= (const List &original_copy)
list_type & operator[] (unsigned long position)
void insert (list_type input, unsigned long position)
void insert (list_type input)
void replace (list_type input, list_type filler, unsigned long position)
void replace (list_type input)
void del (unsigned long position)
void del ()
unsigned long getIndexOf (list_type input)
const unsigned long size (void)
void clear (void)
void compress (void)

Private Attributes

list_type * array
unsigned long list_size
unsigned long allocation_size


Detailed Description

template<class list_type>
class BasicDataStructures::List< list_type >

List ADT (Array Style) - By Kevin Jenkins Initialize with the following structure List<TYPE, OPTIONAL INITIAL ALLOCATION SIZE>

Has the following member functions [x] - Overloaded: Returns element x (starting at 0) in the list between the brackets. If no x argument is specified it returns the last element on the list. If x is invalid it returns 0 size - returns number of elements in the list insert(item, x) - inserts <item> at position x in the list. If no x argument is specified it adds item to the end of the list replace(item, filler, x) - replaces the element at position x with <item>. If x is greater than the current list size, the list is increased and the other values are assigned filler del(OPTIONAL x) - deletes the element at position x. If no x argument is specified it deletes the last element on the list compress - reallocates memory to fit the number of elements. Best used when the number of elements decreases clear - empties the list and returns storage The assignment and copy constructor operators are defined

EXAMPLE

 List<int, 20> A;
 A.size; // Returns 0
 A.insert(10);  // Adds 10 to the end of the list
 A[0];  // Returns 10
 A.insert(1,0);  // Adds 1 to front of list so list reads 1,10
 A.replace(5,0, 1); // Replaces element 1 with a 5.  List reads 1,5
 A.del();  // Deletes the last item on the list. List reads 1
 A.size; // Returns 1

Note:
The default initial allocation size is 1. This function doubles the amount of memory allocated when the list is filled This list is held in an array and is best used for random element selection


Constructor & Destructor Documentation

template<class list_type>
BasicDataStructures::List< list_type >::List  ) 
 

Default constructor

template<class list_type>
BasicDataStructures::List< list_type >::~List  ) 
 

Destructor

template<class list_type>
BasicDataStructures::List< list_type >::List const List< list_type > &  original_copy  ) 
 

Copy constructor

Parameters:
original_copy The list to duplicate


Member Function Documentation

template<class list_type>
void BasicDataStructures::List< list_type >::clear void   ) 
 

Clear the list

template<class list_type>
void BasicDataStructures::List< list_type >::compress void   ) 
 

Compress the list, to meet the current state of the list.

Attention:
Do not use too often this operation if you are doing a lot of insert/del operation because it implies memory realocation and copy of the element of the list.

template<class list_type>
void BasicDataStructures::List< list_type >::del  )  [inline]
 

Delete the element at the end of the list

template<class list_type>
void BasicDataStructures::List< list_type >::del unsigned long  position  ) 
 

Delete the element at position position.

Parameters:
position the index of the element to delete

template<class list_type>
unsigned long BasicDataStructures::List< list_type >::getIndexOf list_type  input  ) 
 

Returns the index of the specified item or MAX_UNSIGNED_LONG if not found

Parameters:
input The element to check for
Returns:
The index or position of input in the list. If input is not in the list MAX_UNSIGNED_LONG is returned.

template<class list_type>
void BasicDataStructures::List< list_type >::insert list_type  input  ) 
 

Insert at the end of the list.

Parameters:
input The new element.

template<class list_type>
void BasicDataStructures::List< list_type >::insert list_type  input,
unsigned long  position
 

Insert an element at position position in the list

Parameters:
input The new element.
position The position of the new element.

template<class list_type>
List< list_type > & BasicDataStructures::List< list_type >::operator= const List< list_type > &  original_copy  ) 
 

template<class list_type>
list_type & BasicDataStructures::List< list_type >::operator[] unsigned long  position  )  [inline]
 

Access an element by its index in the array

Parameters:
position The index in the array.
Returns:
the element at position position.

template<class list_type>
void BasicDataStructures::List< list_type >::replace list_type  input  )  [inline]
 

replace the last element of the list by input

Parameters:
input the element used to replace the last element.

template<class list_type>
void BasicDataStructures::List< list_type >::replace list_type  input,
list_type  filler,
unsigned long  position
[inline]
 

replace the value at position by input. If the size of the list is less than position, it increase the capacity of the list and fill slot with filler.

Parameters:
input The element to replace at position position.
filler The element use to fill new allocated capacity.
position The position of input in the list.

template<class list_type>
const unsigned long BasicDataStructures::List< list_type >::size void   )  [inline]
 

Get the size of the list


Member Data Documentation

template<class list_type>
unsigned long BasicDataStructures::List< list_type >::allocation_size [private]
 

Size of array

template<class list_type>
list_type* BasicDataStructures::List< list_type >::array [private]
 

Store all values

template<class list_type>
unsigned long BasicDataStructures::List< list_type >::list_size [private]
 

Number of element in the list


The documentation for this class was generated from the following file:
Generated on Mon May 30 17:45:43 2005 for raknet by  doxygen 1.4.2