array_of_abstract_t Class Template Reference

Simple resizable container representing 1-dimensional array. More...

#include <array_of_abstract.hh>

List of all members.

Public Types

typedef
array_of_abstract_iterator_t
< T, const T ** > 
const_iterator
 Constant iterator.
typedef
array_of_abstract_iterator_t
< T, T ** > 
iterator
 Iterator.

Public Member Functions

 array_of_abstract_t (const array_of_abstract_t< T, SingleAlloc > &to_copy)
 A copy constructor.
 array_of_abstract_t (const void *params, size_int_t allocate=2, size_int_t step=2)
void assign_from (const array_of_abstract_t< T, SingleAlloc > &to_copy)
 Copies `to_copy' to this container.
const T & back () const
 Returns a constant reference to the last item in the container.
T & back ()
 Returns a reference to the last item in the container.
const_iterator begin () const
 Returns a constant iterator pointing to the first item of the container.
iterator begin ()
 Returns an iterator pointing to the first item of the container.
void clear ()
 Lowers the size of array to zero, but does not release allocated memory.
const_iterator end () const
iterator end ()
void extend (const size_int_t count)
 Extends the container by count members.
void extend_to (const size_int_t count)
 Extends the container to the size of `count' elements.
const T & front () const
 Returns a constant reference to the first item in the container.
T & front ()
 Returns a reference to the first item in the container.
size_int_t get_alloc_step () const
 Returns an allocation step.
size_int_t get_allocated () const
 Returns a count of items allocated in a memory of this container.
const_iterator last () const
 Returns a constant iterator pointing to the last item of the container.
iterator last ()
 Returns an iterator pointing to the last item of the container.
const T & operator[] (const size_int_t i) const
 Returns a constant reference to `i'-th item in the container.
T & operator[] (const size_int_t i)
 Returns a reference to `i'-th item in the container.
pop_back ()
 Removes the last item from the container.
void push_back (T what)
 Appends `what' to the end of the container.
void resize (const size_int_t count)
 Resizes the container to the size of `count' elements.
void set_alloc_step (const size_int_t new_alloc_step)
 Sets an alloc_step step.
void shrink_to (const size_int_t count)
 Shrinks the container to the size of `count' elements.
size_int_t size () const
 Returns a count of items stored in a container.
void swap (array_of_abstract_t< T, SingleAlloc > &second)
 Swaps the containment of instance `second' and this.
 ~array_of_abstract_t ()
 A destructor.

Protected Attributes

T * field
 The entire field of objects stored in array_t.


Detailed Description

template<class T, T *(*)(const void *params) SingleAlloc>
class array_of_abstract_t< T, SingleAlloc >

Simple resizable container representing 1-dimensional array.

This container reimplements array_t template for cases of abstract classes. They cannot be normally instantiated, therefore this container stores only pointers to them. In fact it stores pointers to the childs of the abstract class.

This container presumes, that all items have the same (but unknown) type derived from T (where T is a parameter of template). The unknown type is given by the function SingleAlloc given as a second parameter of a template. SingleAlloc creates the instance of the unknown type and returns it in the form of pointer to the abstract class.

This has been espesially useful in an implementation of enabled_trans_container_t, derived from array_of_abstract_t. It enables enabled_trans_container_t to be relatively fast (no redundant allocation and deallocation) and universal for all possible systems.


Member Typedef Documentation

typedef array_of_abstract_iterator_t<T, const T**> const_iterator

Constant iterator.

Constant iterator - you cannot change the value to which the iterator points. Dereferencing, increasing and descresing takes time O(1) and it is really fast.

typedef array_of_abstract_iterator_t<T, T**> iterator

Iterator.

Iterator. Dereferencing, increasing and descresing takes time O(1) and it is really fast.


Constructor & Destructor Documentation

array_of_abstract_t ( const void *  params,
size_int_t  allocate = 2,
size_int_t  step = 2 
) [inline]

A constructor

Parameters:
params = parameters of allocation


Member Function Documentation

void assign_from ( const array_of_abstract_t< T, SingleAlloc > &  to_copy  )  [inline]

Copies `to_copy' to this container.

Copies the entrire contents of one instance of container to another one.

This operation takes both memory and time O(n), where n is a number of items in to_copy instance of the container.

const_iterator begin (  )  const [inline]

Returns a constant iterator pointing to the first item of the container.

It is really fast operation running in time O(1)

iterator begin (  )  [inline]

Returns an iterator pointing to the first item of the container.

It is really fast operation running in time O(1)

Referenced by dve_explicit_system_t::append_new_enabled(), and dve_explicit_system_t::get_async_enabled_trans().

void clear (  )  [inline]

Lowers the size of array to zero, but does not release allocated memory.

Lowers the size of array to zero, but does not release allocated memory. It is the same as shrink_to(0).

Reimplemented in enabled_trans_container_t.

Referenced by enabled_trans_container_t::clear().

const_iterator end (  )  const [inline]

Returns a constant iterator pointing immediatelly behind the last item of the container

It is really fast operation running in time O(1)

iterator end (  )  [inline]

Returns an iterator pointing immediatelly behind the last item of the container

It is really fast operation running in time O(1)

void extend ( const size_int_t  count  )  [inline]

Extends the container by count members.

Parameters:
count = the count of items we want to add to the container
Its running time is O(n), where n is a number of items stored in the container.

Referenced by dve_explicit_system_t::append_new_enabled(), dve_explicit_system_t::append_new_enabled_prop_sync(), dve_explicit_system_t::compute_successors_without_sync(), por_t::generate_composed_ample_sets(), dve_explicit_system_t::get_async_enabled_trans(), and dve_explicit_system_t::get_sync_succs_internal().

void extend_to ( const size_int_t  count  )  [inline]

Extends the container to the size of `count' elements.

Warning:
Important: This method presumes, that count >= size().
Its running time is O(n), where n is a number of items stored in the container.

size_int_t get_alloc_step (  )  const [inline]

Returns an allocation step.

Returns an allocation step. Allocation step is the least step of allocation of new items (we always allocate the number of items, which is divisible by get_alloc_step())

size_int_t get_allocated (  )  const [inline]

Returns a count of items allocated in a memory of this container.

Returns a count of items allocated in a memory of this container. It's return value is always more or equal to return value of size()

const_iterator last (  )  const [inline]

Returns a constant iterator pointing to the last item of the container.

It is really fast operation running in time O(1)

iterator last (  )  [inline]

Returns an iterator pointing to the last item of the container.

It is really fast operation running in time O(1)

T pop_back (  )  [inline]

Removes the last item from the container.

Removes the last item from the container and returns its value. It doesn't relesase the memory allocated for the last item (this memory will be reused in the next push_back()) - therefore it runs in a time O(1) and it it really fast operation.

void push_back ( what  )  [inline]

Appends `what' to the end of the container.

Appends what to the end of the container. If neccessary it extends the allocated memory. Therefore in that case it runs in a timeO(n), where n is a number of items stored in the container.

void resize ( const size_int_t  count  )  [inline]

Resizes the container to the size of `count' elements.

It is implemented using shrink_to() and extend_to() methods. Therefore if count <= size() it runs in a time O(1) (it uses shrink_to() method), otherwise it runs in a time O(n) (it uses extend_to() method), where n is a number of items stored in the container.

void set_alloc_step ( const size_int_t  new_alloc_step  )  [inline]

Sets an alloc_step step.

Sets an allocation step. Allocation step is the least step of allocation of new items (we always allocate the number of items, which is divisible by get_alloc_step())

void shrink_to ( const size_int_t  count  )  [inline]

Shrinks the container to the size of `count' elements.

Warning:
Important: This method presumes, that count <= size().
Its running time is O(1) and it is really fast operation

void swap ( array_of_abstract_t< T, SingleAlloc > &  second  )  [inline]

Swaps the containment of instance `second' and this.

Swaps the containment of instance `second' and this. On one hand (unlike assign_from()) it changes its parameter, but on the other hand it runs only in O(1) time, what is much faster than the running time of assign_from()


The documentation for this class was generated from the following file:

Reference Manual for Library, 2006 developed in ParaDiSe laboratory, Faculty of Informatics, Masaryk University