PIGALE 1.3.9 Documentation (original) (raw)
P.I.G.A.L.E.
1.3.9
Public Implementation of a Graph Algorithm
Library and Editor
H. de Fraysseix P. Ossona de Mendez
_svector Class Reference
Detailed Description
Simple dynamic scalar vector [start:finish-1].
A scalar vector handles data types without constructor or destructor, that may be copied using a binary copy. This "base" class is untyped; all what is known here about the vector elements are their size. Therefore, any auxiliary storage needs dynamicaly allocated memory. In order not to fraction the memory and not to call allocation more than necessary, the vector data buffer includes two extra rooms: one for temporary storage, the other one to store a default value. Moreover, allocation is done by increments configured by TSVECTOR_INCREMENT constant. Therefore, the buffer bounds may differ from the user bounds. User bounds will correspond to interval [start;finish[ (finish excluded), although available bounds will be [_start+2;_finish[, as two extra rooms are allocated. The reallocation and reservation method will be as follows:
- if the vector only handles positive or null indices (_start+2 >= 0), the buffer will only grow on its right side (upper indices)
- if the buffer handles both positive and negative indices, the buffer will grow both side symetrically.
Public Member Functions
- void reserve (int a, int b)
- _svector ()
- _svector (int a, int b, int size_elt, const void *p=0)
- _svector (const _svector &s)
- ~_svector ()
- int empty () const
- int InRange (int index) const
- int getsize () const
- int n () const
- int SizeElmt () const
- int starti () const
- int stopi () const
- void * begin ()
- const void * begin () const
- void * origin ()
- const void * origin () const
- void * end ()
- const void * end () const
- void resize (int a, int b)
- void clear ()
- void fill (int from, int to, char byte=0)
- void reset (int a, int b)
- void reset ()
- void Tswap (_svector &s)
- _svector & operator= (const _svector &s)
- const void * pinit () const
- void * pinit ()
- void definit (const void *p)
- void SetName (const char *txt)
- const char * GetName () const
- void check (int) const
- void SwapIndex (int a, int b)
- void CopyIndex (int a, int b)
- void qsort (int(*compare)(const void *, const void *))
- bool operator== (const _svector &v) const
- bool operator!= (const _svector &v) const
Protected Member Functions
- int InBuffRange (int index) const
- void * tmpptr ()
- const void * tmpptr () const
- void * ptr (int i)
- const void * ptr (int i) const
- void ReserveGrow (int a, int b)
- void realloc_buffer ()
- void vreserve (int s, int f, T_STD size_t nsize_elmt)
- _svector & copy (const _svector &s)
Protected Attributes
- int start
- int finish
- void * ptr0
- void * buff
- int _start
- int _finish
- T_STD size_t size_elmt
- void * init
- char name [16]
Friends
Constructor & Destructor Documentation
Empty vector constructor.
No allocation performed at all for efficiency (transient state)
| _svector | ( | int | a, |
|---|---|---|---|
| int | b, | ||
| int | size_elt, | ||
| const void * | p = 0 | ||
| ) | [inline] |
Constructs vector [a:b] of elements of size size_elt init to *p.
Member Function Documentation
| int InBuffRange | ( | int | index | ) | const [inline, protected] |
|---|
Checks if index may be valid for buff without reallocation.
| void* tmpptr | ( | | ) | [inline, protected] | | ------------- | - | | - | --------------------- |
Pointer to temporary element at index _start+1.
| const void* tmpptr | ( | | ) | const [inline, protected] | | ------------------- | - | | - | --------------------------- |
| void* ptr | ( | int | i | ) | [inline, protected] |
|---|
Returns pointer to user element at index i.
| const void* ptr | ( | int | i | ) | const [inline, protected] |
|---|
| void ReserveGrow | ( | int | a, |
|---|---|---|---|
| int | b | ||
| ) | [inline, protected] |
Makes sure vector can be indexed in range [a:b].
If a resize has to be performed, the size increment will be at least equal to TSVECTOR_INCREMENT. If the vector may handle negative user indices (start<0) or growth is requested both sides, growth is performed in a symetric way.
| void realloc_buffer | ( | | ) | [inline, protected] | | -------------------- | - | | - | --------------------- |
Reallocates buffer to hold (_finish-_start) elements.
| void reserve | ( | int | a, |
|---|---|---|---|
| int | b | ||
| ) | [inline] |
Reserves rooms to handle [a;b].
This methods concerns the case where the extremal user bounds are known in advance. In such a case, we want a tight allocation (no need to reserve more that what we know to be possibly used).
| void vreserve | ( | int | s, |
|---|---|---|---|
| int | f, | ||
| T_STD size_t | nsize_elmt | ||
| ) | [inline, protected] |
Makes buffer [s:f] with elements of size nsize_elmt.
This method will be used to "reformat" a vector during a copy operation. Two cases may occur: if the new element size is equal to the old element size, we assume that the default value (when set) will still be valid. It is hence copied, should a reallocation occur. Otherwise, default value is unset.
copy helper (for copy constructor and assignment)
| int empty | ( | | ) | const [inline] | | --------- | - | | - | ---------------- |
Tests whether vector is empty (no elements).
| int InRange | ( | int | index | ) | const [inline] |
|---|
Checks whether user index is valid for vector.
| int getsize | ( | | ) | const [inline] | | ----------- | - | | - | ---------------- |
Returns size of vector in bytes.
Returns length of vector in number of elements.
| int SizeElmt | ( | | ) | const [inline] | | ------------ | - | | - | ---------------- |
Returns size of a single element in bytes.
| int starti | ( | | ) | const [inline] | | ---------- | - | | - | ---------------- |
Returns first index of vector.
| int stopi | ( | | ) | const [inline] | | --------- | - | | - | ---------------- |
Returns 1 past-end index of vector.
Returns pointer to first element of vector.
Reimplemented in svector, svector< long >, svector< double >, svector< vProp1 * >, svector< Taxi_FileIO * >, svector< tbrin >, svector< ColorItem * >, svector< Point3_ >, svector< int >, svector< _svector * >, svector< Taxi_rgb >, svector< short >, svector< ThickItem * >, svector< void * >, svector< char >, svector< vProp * >, svector< bool >, svector< svector< double > * >, svector< tvertex >, svector< tedge >, svector< Point2_ >, and svector< char * >.
| const void* begin | ( | | ) | const [inline] | | ------------------ | - | | - | ---------------- |
Reimplemented in svector, svector< long >, svector< double >, svector< vProp1 * >, svector< Taxi_FileIO * >, svector< tbrin >, svector< ColorItem * >, svector< Point3_ >, svector< int >, svector< _svector * >, svector< Taxi_rgb >, svector< short >, svector< ThickItem * >, svector< void * >, svector< char >, svector< vProp * >, svector< bool >, svector< svector< double > * >, svector< tvertex >, svector< tedge >, svector< Point2_ >, and svector< char * >.
| void* origin | ( | | ) | [inline] | | ------------- | - | | - | ---------- |
Returns pointer to element at index 0.
Reimplemented in svector, svector< long >, svector< double >, svector< vProp1 * >, svector< Taxi_FileIO * >, svector< tbrin >, svector< ColorItem * >, svector< Point3_ >, svector< int >, svector< _svector * >, svector< Taxi_rgb >, svector< short >, svector< ThickItem * >, svector< void * >, svector< char >, svector< vProp * >, svector< bool >, svector< svector< double > * >, svector< tvertex >, svector< tedge >, svector< Point2_ >, and svector< char * >.
| const void* origin | ( | | ) | const [inline] | | ------------------- | - | | - | ---------------- |
Reimplemented in svector, svector< long >, svector< double >, svector< vProp1 * >, svector< Taxi_FileIO * >, svector< tbrin >, svector< ColorItem * >, svector< Point3_ >, svector< int >, svector< _svector * >, svector< Taxi_rgb >, svector< short >, svector< ThickItem * >, svector< void * >, svector< char >, svector< vProp * >, svector< bool >, svector< svector< double > * >, svector< tvertex >, svector< tedge >, svector< Point2_ >, and svector< char * >.
Returns pointer to 1 past-end element.
Reimplemented in svector, svector< long >, svector< double >, svector< vProp1 * >, svector< Taxi_FileIO * >, svector< tbrin >, svector< ColorItem * >, svector< Point3_ >, svector< int >, svector< _svector * >, svector< Taxi_rgb >, svector< short >, svector< ThickItem * >, svector< void * >, svector< char >, svector< vProp * >, svector< bool >, svector< svector< double > * >, svector< tvertex >, svector< tedge >, svector< Point2_ >, and svector< char * >.
| const void* end | ( | | ) | const [inline] | | ---------------- | - | | - | ---------------- |
Reimplemented in svector, svector< long >, svector< double >, svector< vProp1 * >, svector< Taxi_FileIO * >, svector< tbrin >, svector< ColorItem * >, svector< Point3_ >, svector< int >, svector< _svector * >, svector< Taxi_rgb >, svector< short >, svector< ThickItem * >, svector< void * >, svector< char >, svector< vProp * >, svector< bool >, svector< svector< double > * >, svector< tvertex >, svector< tedge >, svector< Point2_ >, and svector< char * >.
| void resize | ( | int | a, |
|---|---|---|---|
| int | b | ||
| ) | [inline] |
Resize vector to index range [a:b].
Clears all elements to 0.
| void fill | ( | int | from, |
|---|---|---|---|
| int | to, | ||
| char | byte = 0 | ||
| ) | [inline] |
Fill vector [from:to] with byte values.
| void reset | ( | int | a, |
|---|---|---|---|
| int | b | ||
| ) | [inline] |
Sets vector [a:b] to initial value (if defined).
Sets all vector elements to initial value (if defined).
| const void* pinit | ( | | ) | const [inline] | | ------------------ | - | | - | ---------------- |
Returns pointer to initial value.
Reimplemented in svector, svector< long >, svector< double >, svector< vProp1 * >, svector< Taxi_FileIO * >, svector< tbrin >, svector< ColorItem * >, svector< Point3_ >, svector< int >, svector< _svector * >, svector< Taxi_rgb >, svector< short >, svector< ThickItem * >, svector< void * >, svector< char >, svector< vProp * >, svector< bool >, svector< svector< double > * >, svector< tvertex >, svector< tedge >, svector< Point2_ >, and svector< char * >.
| void definit | ( | const void * | p | ) | [inline] |
|---|
Defines p to be the initial value. When 0, clears it.
| void SetName | ( | const char * | txt | ) | [inline] |
|---|
| const char* GetName | ( | | ) | const [inline] | | -------------------- | - | | - | ---------------- |
| void check | ( | int | | ) | const [inline] | | ---------- | - | --- | | - | ---------------- |
| void SwapIndex | ( | int | a, |
|---|---|---|---|
| int | b | ||
| ) | [inline] |
Swaps elements indexed by a and b.
Reimplemented in svector, svector< long >, svector< double >, svector< vProp1 * >, svector< Taxi_FileIO * >, svector< tbrin >, svector< ColorItem * >, svector< Point3_ >, svector< int >, svector< _svector * >, svector< Taxi_rgb >, svector< short >, svector< ThickItem * >, svector< void * >, svector< char >, svector< vProp * >, svector< bool >, svector< svector< double > * >, svector< tvertex >, svector< tedge >, svector< Point2_ >, and svector< char * >.
| void CopyIndex | ( | int | a, |
|---|---|---|---|
| int | b | ||
| ) | [inline] |
| void qsort | ( | int(*)(const void *, const void *) | compare | ) | [inline] |
|---|
| bool operator== | ( | const _svector & | v | ) | const [inline] |
|---|
| bool operator!= | ( | const _svector & | v | ) | const [inline] |
|---|
Friends And Related Function Documentation
Member Data Documentation
char name[16] [protected]
