Container of Numbers.
More...
#include <rnumcontainer.h>
|
| RNumContainer (size_t max) |
|
| RNumContainer (const RNumContainer &vector) |
|
void | Verify (size_t max) |
|
void | Init (size_t nb, I val) |
|
int | Compare (const RNumContainer< I, bOrder > &) const |
|
size_t | GetIndex (I nb, bool &find) const |
|
bool | IsSame (const RNumContainer &vi) const |
|
bool | IsIn (I value) const |
|
size_t | Insert (I ins) |
|
void | InsertAt (I ins, size_t pos, bool replace=false) |
|
void | Delete (I del) |
|
void | DeleteAt (size_t pos, bool shift=true) |
|
void | Clear (void) |
|
void | ReOrder (void) |
|
void | Randomize (RRandom *rand, size_t nb=0) |
|
template<bool bOrder1> |
RNumContainer & | operator= (const RNumContainer< I, bOrder1 > &src) |
|
template<bool bOrder1> |
RNumContainer< I, bOrder > & | Add (const RNumContainer< I, bOrder1 > &src) |
|
I | operator[] (size_t i) const |
|
I & | operator[] (size_t i) |
|
const I * | GetList (void) const |
|
size_t | GetNb (void) const |
|
template<bool bOrder1, bool bOrder2> |
void | Inter (const RNumContainer< I, bOrder1 > &src1, const RNumContainer< I, bOrder2 > &src2) |
|
template<bool bOrder1, bool bOrder2> |
void | Union (const RNumContainer< I, bOrder1 > &src1, const RNumContainer< I, bOrder2 > &src2) |
|
| ~RNumContainer (void) |
|
template<class I, bool bOrder = true>
class R::RNumContainer< I, bOrder >
Container of Numbers.
The RNumContainer class provides a representation of a container of numbers.
- Template Parameters
-
I | Type (int, double, etc.). |
bOrder | Is the container ordered? |
- Warning
- Some methods applied on an ordered container can disorder the container.
Construct the list of values.
- Parameters
-
max | Maximum number of values. |
Copy constructor.
- Parameters
-
void Verify |
( |
size_t |
max | ) |
|
Verify if the container can hold a certain number of elements. If not, the container is extended.
- Parameters
-
max | Number of elements that must be contained. |
void Init |
( |
size_t |
nb, |
|
|
I |
val |
|
) |
| |
Initialize the container with a given values.
- Parameters
-
nb | Number of elements. |
val | Value used to initialize. |
Compare method that can be used to construct an unordered container of containers.
size_t GetIndex |
( |
I |
nb, |
|
|
bool & |
find |
|
) |
| const |
This function returns the index of an element represented by tag, and it is used when the elements are to be ordered.
- Parameters
-
nb | Number to find. |
find | If the element represented by tag exist, find is set to true. |
- Returns
- Returns the index of the element if it exists or the index where is has to inserted.
Test if two lists have exactly the same values.
- Parameters
-
vi | The list used for the comparison. |
- Returns
- True if the lists are the same.
bool IsIn |
( |
I |
value | ) |
const |
Verify if a value is in the list.
- Parameters
-
- Returns
- True if the value is in the list, false else.
Insert an value in the list. If the vector is ordered, the method verifies that the value is not in before insertion. If the vector is unordered, the value is simply inserted at the end.
- Parameters
-
- Returns
- the position of the value in the list.
void InsertAt |
( |
I |
ins, |
|
|
size_t |
pos, |
|
|
bool |
replace = false |
|
) |
| |
Insert a value in the list at a given position.
- Parameters
-
ins | The value to insert. |
pos | The position where to insert. |
replace | Specify if the value that was previously at the position should be replaced or shifted. |
- Warning
- If applied on an ordered container, this method can disorder it.
Delete a value in the list.
- Parameters
-
void DeleteAt |
( |
size_t |
pos, |
|
|
bool |
shift = true |
|
) |
| |
Delete an element at a given position.
- Parameters
-
pos | Position of the element to remove. |
shift | Must the elements be shifted. |
- Warning
- If applied on an ordered container, this method can disorder it.
static int ReOrderFunction |
( |
const void * |
num1, |
|
|
const void * |
num2 |
|
) |
| |
|
staticprivate |
Static function needed to order a list.
Reorder the current list of values in ascending order.
void Randomize |
( |
RRandom * |
rand, |
|
|
size_t |
nb = 0 |
|
) |
| |
Randomize the list.
- Parameters
-
rand | Random number generator to use. |
nb | Number of first element to randomize. If null, all values are randomized. |
- Warning
- If applied on an ordered container, this method can disorder it.
Assignment operator.
- Template Parameters
-
bOrder1 | Is the list ordered? |
- Parameters
-
src | List used for the assignment. |
Insert all the values of a list in the current one. This function supposes that the list to insert don't contain any value already in the current list.
- Template Parameters
-
bOrder1 | Is the list ordered? |
- Parameters
-
I operator[] |
( |
size_t |
i | ) |
const |
Return the value at position i. The first value is at position 0.
- Parameters
-
I& operator[] |
( |
size_t |
i | ) |
|
Return the value at position i. The first value is at position 0.
- Parameters
-
- Warning
- If applied on an ordered container, this method can disorder it.
const I* GetList |
( |
void |
| ) |
const |
Get the list of the values contained in the vector.
size_t GetNb |
( |
void |
| ) |
const |
Get the number of values in the list.
- Returns
- size_t
Compute the intersection of two lists. The list is emptied. before.
- Template Parameters
-
bOrder1 | Is the first list ordered? |
bOrder2 | Is the second list ordered? |
- Parameters
-
src1 | First list. |
src2 | Second list. |
Compute the union of two lists. The list is emptied. before.
- Template Parameters
-
bOrder1 | Is the first list ordered? |
bOrder2 | Is the second list ordered? |
- Parameters
-
src1 | First list. |
src2 | Second list. |
Number of values in the list.
Maximal number of values in the list.
The array representing the values.