Evoplex
0.2.1
|
A container of labeled values. More...
#include <attributes.h>
Public Member Functions | |
Attributes (int size) | |
Constructor. More... | |
Attributes () | |
Constructor. | |
~Attributes () | |
Destructor. | |
void | resize (int size) |
Resizes the container to the specified number of elements. More... | |
void | reserve (int size) |
Attempt to preallocate enough memory for specified number of elements. More... | |
int | size () const |
Gets the number of attributes in the container. | |
bool | isEmpty () const |
Checks if the container is empty. | |
bool | empty () const |
Checks if the container is empty. More... | |
int | indexOf (const QString &name) const |
Returns the index position of name in the container. More... | |
bool | contains (const QString &name) const |
Checks if the container contains name . More... | |
void | replace (int id, QString newName, Value newValue) |
Replaces the item at index position id with newName and newValue . More... | |
void | push_back (QString name, Value value) |
Appends the attribute name with the value value . More... | |
const std::vector< QString > & | names () const |
Gets the name of all attributes. | |
const QString & | name (int id) const |
Gets the name of the attribute at id . More... | |
const std::vector< Value > & | values () const |
Gets the values of all attributes. | |
const Value & | value (int id) const |
Gets the value of the attribute at id . More... | |
Value | value (const QString &name, Value defaultValue=Value()) const |
Gets the value corresponding to name . More... | |
void | setValue (int id, const Value &value) |
Sets the value at id . More... | |
A container of labeled values.
It offers fixed time access to individual elements in any order by id and linear time by name.
|
inline |
Constructor.
size | The containers size. |
|
inline |
Checks if the container contains name
.
name | The attribute's name. |
|
inline |
Checks if the container is empty.
|
inline |
Returns the index position of name
in the container.
name | The attribute's name. |
|
inline |
Gets the name of the attribute at id
.
std::out_of_range | if the id is not present. |
|
inline |
Appends the attribute name
with the value value
.
name | The attribute's name. |
value | The attribute's value. |
|
inline |
Replaces the item at index position id
with newName
and newValue
.
id | The attribute's id. |
newName | The new attribute's name. |
newValue | The new attribute's value. |
std::out_of_range | if the id is not present. |
|
inline |
Attempt to preallocate enough memory for specified number of elements.
This function attempts to reserve enough memory for the container to hold the specified number of elements. If the number requested is more than max_size(), length_error is thrown.
size | Number of elements required. |
std::length_error | If size n exceeds maximum size. |
|
inline |
Resizes the container to the specified number of elements.
This function will resize the container to the specified number of elements. If the number is smaller than the container's current size the container is truncated, otherwise default constructed elements, i.e., empty name and Value() are appended.
size | Number of elements the container should contain. |
|
inline |
Sets the value at id
.
id | The attribute's id. |
value | The new attribute's value. |
std::out_of_range | if the id is not present. |
|
inline |
Gets the value of the attribute at id
.
id | The attribute's id. |
std::out_of_range | if the id is not present. |
|
inline |
Gets the value corresponding to name
.
name | The attribute's name. |
defaultValue | A Value to be returned if name is not present. |