libidx
ebl::svector< T > Class Template Reference

#include <smart.h>

Inheritance diagram for ebl::svector< T >:
vector ebl::smart_pointer

List of all members.

Classes

class  const_iterator
 Custom iterator for svector. More...
class  iterator
 Custom iterator for svector. More...

Public Member Functions

 svector ()
 Default constructor.
 svector (const svector< T > &other)
 Construct from another svector.
 svector (uint n)
 Constructs a vector of n empty elements.
virtual void clear ()
 Unlocks all elements and clears the pointers in this vector.
virtual void clear (uint i)
 Unlocks element 'i' and set it to empty (NULL).
virtual T & operator[] (uint i)
 Returns a reference to T at index 'i'.
virtual const T & at_const (uint i) const
 Returns a reference to T at index 'i'.
virtual bool exists (uint i) const
 Returns true if element 'i' is empty, false otherwise.
virtual uint size_existing () const
 Returns the number of non-empty elements.
virtual void remove (uint i)
virtual void remove (uint start, uint end)
 Remove all elements between 'start' and 'end' (included).
virtual void remove_empty ()
virtual void push_front (T &e)
 Lock 'e' and and push its address to the front of this.
virtual void push_front_new (T &e)
 Allocates a copy of 'e', lock it and push it to the front of this.
virtual void push_back (T *e)
 Lock and push an element 'e' to the end of this vector.
virtual void push_back (T &e)
 Lock and push an element 'e' to the end of this vector.
virtual void push_back_new (const T &e)
 Allocates a copy of 'e', lock it and push it to the end of this vector.
virtual void push_back_new (const T *e)
 Allocates a copy of 'e', lock it and push it to the end of this vector.
virtual void push_back (std::vector< T * > &v)
 Lock and push all elements of 'v' to the end of this vector.
virtual void push_back (svector< T > &v)
 Lock and push all elements of 'v' to the end of this vector.
virtual void push_back_new (const svector< T > &v)
 Allocate new, lock and push all elements of 'v' to the end of this.
virtual void push_back_empty ()
 Push an empty element (null) to the end of this vector.
virtual void set (T &e, uint n)
 Unlocks element at index 'n' and replace it with 'e' (and lock it).
virtual void set_new (T &e, uint n)
 Unlocks element at index 'n' and replace it with a new 'e'(and lock it).
virtual void operator= (svector< T > v)
 Clear all elements, then lock and push all elements of 'v' to the end.
virtual void swap (uint i, uint j)
 Swap elements 'i' and 'j'.
virtual svector< T > copy ()
 Returns a svector that contains copies of each element of this.
virtual void copy (const svector< T > &other)
 Clear this and allocate copies of all elements of 'other' into this one.
virtual void copy (svector< T > &other)
 Clear this and allocate copies of all elements of 'other' into this one.
virtual svector< T > narrow (uint n, uint offset)
 Returns an midxd with 'n' elements starting at 'offset'.
virtual void resize_default (uint n)
virtual void randomize ()
 Randomizes order of elements.
virtual iterator begin (uint offset=0)
virtual const_iterator begin (uint offset=0) const
void lock_all ()

Protected Member Functions

void unlock_all ()
 Unlock all idx contained in this midx.
void unlock_range (uint start, uint end)
 Unlock all elements between 'start' and 'end' (included).

Protected Attributes

std::vector< T * >::iterator it

Detailed Description

template<class T>
class ebl::svector< T >

A smart vector that handles smart pointers, i.e. this vector must be given dynamically allocated objects and will handle their deletion automatically.


Member Function Documentation

template<class T >
svector< T >::iterator ebl::svector< T >::begin ( uint  offset = 0) [virtual]

Returns an iterator pointing to the beginning of this vector.

Parameters:
offsetStart at begin + offset.
template<class T >
svector< T >::const_iterator ebl::svector< T >::begin ( uint  offset = 0) const [virtual]

Returns an iterator pointing to the beginning of this vector.

Parameters:
offsetStart at begin + offset.
template<class T >
void ebl::svector< T >::lock_all ( )

Lock all idx contained in this midx, so that they are not deleted if other midx referencing them unlock them.

template<class T >
void ebl::svector< T >::remove ( uint  i) [virtual]

Unlocks element 'i' and erase the vector element (shifting all above) down by 1 element and decreasing size() by 1.

template<class T >
void ebl::svector< T >::remove_empty ( ) [virtual]

Erases all elements that are empty (!exists()), reducing the size of this vector by n if n elements are empty.

template<class T >
void ebl::svector< T >::resize_default ( uint  n) [virtual]

Pushes new elements of type T with default empty constructor until reaching size of n.


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