BasicAlgos Class Reference

#include </home/scilab/compilation_chain/sci_checkOut/scilab/modules/renderer/src/cpp/BasicAlgos.hxx>


Static Public Member Functions

static char ** createStringArray (int nbElement)
static void stringArrayCopy (char *dest[], char *src[], int nbElement)
static void destroyStringArray (char *src[], int nbElement)
template<typename T>
static bool listContains (std::list< T > &searchedList, T &value)
template<typename T>
static bool vectorRemove (std::vector< T > &searchedVector, T &value)


Detailed Description

Definition at line 20 of file BasicAlgos.hxx.


Member Function Documentation

char ** BasicAlgos::createStringArray ( int  nbElement  )  [static]

Create a new array of char *, with all its elements set to NULL;

Definition at line 18 of file BasicAlgos.cpp.

References i, NULL, and res.

Referenced by sciGraphics::TicksDrawer::drawTicks(), sciGraphics::TicksDrawer::getInitTicksPos(), sciGetJavaXTicksPos(), sciGetJavaYTicksPos(), and sciGetJavaZTicksPos().

00019 {
00020   char ** res = new char *[nbElement];
00021 
00022   for (int i = 0; i < nbElement; i++)
00023   {
00024     res[i] = NULL;
00025   }
00026   return res;
00027 }

Here is the caller graph for this function:

void BasicAlgos::stringArrayCopy ( char *  dest[],
char *  src[],
int  nbElement 
) [static]

copy a char * array into an other

Definition at line 29 of file BasicAlgos.cpp.

References destroyStringArray(), i, and NULL.

Referenced by sciGraphics::UserDefLogTicksComputer::getTicksPosition(), and sciGraphics::UserDefinedTicksComputer::getTicksPosition().

00030 {
00031   int i ;
00032   for ( i = 0 ; i < nbElement ; i++ )
00033   {
00034     int elemSize =  (int) strlen( src[i] ) + 1 ;
00035     if (dest[i] != NULL) {delete[] dest[i]; }
00036 
00037     dest[i] = new char[elemSize] ;
00038 
00039     if ( dest[i] == NULL )
00040     {
00041       destroyStringArray( dest, nbElement ) ;
00042       return ;
00043     }
00044 
00045     strcpy( dest[i], src[i] ) ;
00046   }
00047 }

Here is the call graph for this function:

Here is the caller graph for this function:

void BasicAlgos::destroyStringArray ( char *  src[],
int  nbElement 
) [static]

delete an array of strings

Definition at line 49 of file BasicAlgos.cpp.

References i, and NULL.

Referenced by sciGraphics::TicksDrawer::drawTicks(), sciGraphics::TicksDrawer::getInitTicksPos(), sciGetJavaXTicksPos(), sciGetJavaYTicksPos(), sciGetJavaZTicksPos(), and stringArrayCopy().

00050 {
00051   if (src == NULL) {return;}
00052 
00053   for (int i = 0; i < nbElement; i++)
00054   {
00055     if (src[i] != NULL) {delete[] src[i];}
00056   }
00057   delete[] src;
00058 }

Here is the caller graph for this function:

template<typename T>
static bool BasicAlgos::listContains ( std::list< T > &  searchedList,
T &  value 
) [inline, static]

Find an object inside a list.

Parameters:
searchedList,list in which the value is searched
value searched value
Returns:
ture if the value is find, false otherwise

Definition at line 46 of file BasicAlgos.hxx.

Referenced by getParentFigureList().

00047   {
00048     typename std::list<T>::iterator it = searchedList.begin();
00049     for (; it != searchedList.end(); it++)
00050     {
00051       if (*it == value)
00052       {
00053         return true;
00054       }
00055     }
00056     return false;
00057   }

Here is the caller graph for this function:

template<typename T>
static bool BasicAlgos::vectorRemove ( std::vector< T > &  searchedVector,
T &  value 
) [inline, static]

Remove an object inside a vector.

Parameters:
searchedList,vector in which the value is searched
value searched value
Returns:
ture if the value has been find and removed, false otherwise

Definition at line 66 of file BasicAlgos.hxx.

Referenced by sciGraphics::ConcreteDrawableSubwin::removeTextToDraw().

00067   {
00068     typename std::vector<T>::iterator it = searchedVector.begin();
00069     for (; it != searchedVector.end(); it++)
00070     {
00071       if (*it == value)
00072       {
00073         searchedVector.erase(it);
00074         return true;
00075       }
00076     }
00077     return false;
00078   }

Here is the caller graph for this function:


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

Generated on Tue Sep 9 18:22:59 2008 for Scilab [trunk] by  doxygen 1.5.5