Macros | |
| #define | DLINK_TO_TYPE(type_name, link_name) |
| #define | LINKNAME_TO_TYPE(type_name, link_name) |
| #define | DLINK_TO_BASE(type_name, link_name) |
| #define | SLINK_TO_TYPE(type_name, link_name) |
Typedefs | |
| template<class Container , typename T > | |
| using | GenericKeys = GenericItems< Container, T > |
| template<class Container , typename T > | |
| using | Aleph::GenericKeys = GenericItems< Container, T > |
| template<typename T , class Equal = Aleph::equal_to<T>> | |
| using | Aleph::DynArray_Set = DynArray< T > |
| template<typename T > | |
| using | Aleph::DynListStack = DynList< T > |
Functions | |
| template<typename T , template< typename > class C> | |
| auto | Aleph::shuffle (const C< T > &c) |
| template<typename T , template< typename > class C> | |
| C< T * > | Aleph::shuffle_ptr (const C< T > &c) |
In Aleph-w (
) all data structure based on a linked list or an array is considered a sequence.
Sequences are probably the most used data structures. In Aleph-w (
) the sequences very ofted are used in association with functional methods. These functional features are implemented through of iterators exported by each class representing a sequence. You could so traverse a sequence via an iterator or via a functional method
These are the main Aleph-w (
) sequences:
Arrays: dynamic arrays DynArray and bit arrays ` y arreglos de bits BitArray.
Some special containers oriented to flow are also implemented with arrays. These are DynArrayQueue and DynArrayStack.
Aleph-w (
) doctrine is to export three levels of implementation:Link management: in this level all the problems that requires to handle the links but not to know the data are solved. For example, for concatenating a list to another list is not necessary to know the data contained into the nodes. The only knowledge is the link of extremes of lists. The classes Slinknc and Dlink implement operation on single and double linked list respectively.
This level is very useful for maintaining data related to several lists. For example, suppose a graphical window manager that handles two list: a list of showed windows on the screen and another of hided windows. When a window must be showed, the this windows must be deleted form the list of hided and inserted into the list of showed. This implies that a window must be deleted form a list and then to be inserted into another. With this approach this can be done very efficiently without destroying the window when it is removed from a list and then reconstrunting in order to insert it in the another list.
Another example could be a record that belongs simultaneously to several lists.
Data management: when it is necessary to know the data contained on a node, then the operation is put in this level. The most simple and common situation is when given a node belonging to a linked list we want to obtain its data. In fact, the main work of this level is to cast pointer to links of previous level to pointers to nodes containing data.
In this level we have to main classed Dnode and Snodenc.
In the previous level the memory management is not concerned.
Memory management: the last level does not operate in function of link or nodes. It is the more common and works in function of data types, not of nodes or links. This level manages transparentely the memory.
The main classes of this level are DynList, DynDlist, DynListQueue and DynListStack.
| #define DLINK_TO_BASE | ( | type_name, | |
| link_name | |||
| ) |
Generate a function with name link_to_base() what converts a Dlink pointer to the class or struct that contains it.
This macro could be used when a class have a Dlink field y and from it it is desired to get a pointer to the class. For example, suppose some such as:
struct Record
{
...
Dlink l;
...
};
Then DLINK_TO_BASE(Record, l) will produce the function:
Record * dlink_to_base(Dlink * link)
which receives a pointer to the Dlink field l and return a pointer to the Record object storing l.
| type_name | the name of class of struct containing the Dlink field. |
| link_name | the name of Dlink field inside the class or struct |
| #define DLINK_TO_TYPE | ( | type_name, | |
| link_name | |||
| ) |
Generate a conversion function from a Dlink field to a class containing it.
This macro is used when inside a class exists one o more Dlink fields and it is needed to obtain from a Dlink field a pointer to the class containing it.
For example, suppose the following situation:
struct Record
{
...
Dlink l;
...
};
So, DLINK_TO_TYPE(Record, l) will generate the function:
Record * dlink_to_Record(Dlink * link)
which receives a pointer to the Dlink field l and returns a pointer to the class Record containing l.
| type_name | the name of class or struct containing the Dlink field |
| link_name | the name of the Dlink field inside the class or struct. |
| #define LINKNAME_TO_TYPE | ( | type_name, | |
| link_name | |||
| ) |
Generate a conversion function from a Dlink field pointer to a pointer to the class containing it.
The name of the function is literally the name of second parameter
This macro is used when one o more Dlink field are used inside a class and it is desired to obtain pointers to the class from the Dlink fields. Consider for example,
struct Redcordgistro
{
...
Dlink l1;
Dlink l2;
...
};
So, LINKNAME_TO_TYPE(Record, l1) and LINKNAME_TO_TYPE(Record, l2) will generate the following functions:
Record * l1_to_type(Dlink * link)
Record * l2_to_type(Dlink * link)
So for converting a Dlink pointer to l1 to a pointer to Record object which contains it, you use l1_to_type(link); analogously with l2_to_type(link).
The idea is having naming schemes allowing to distinguish several Dlink fields.
Dlink fields. This situation arises if you want that the class simultaneously belongs to several lists. In this case you would declare a Dlink field by each different list.| type_name | the name of struct or class containing to the Dlink object. |
| link_name | the name of Dlink field |
| #define SLINK_TO_TYPE | ( | type_name, | |
| link_name | |||
| ) |
Genera función de conversión de nombre de enlace simple a estructura que lo contenga. El nombre de la función es literalmente el parámetro que se instancie como link_name
Este macro se utiliza cuando se tiene dos o más Slink que son parte de una estructura y se desea obtener un apuntador a la estructura desde algunos de los enlaces.
Si tenemos, por ejemplo: struct Registro { ... Slink l1; Slink l2; ... };
Entonces slink_TO_TYPE(Registro, l1) y SLINK_TO_TYPE(Registro, l2) generará las funciones:
La idea es disponer de esquemas de nombramiento que prmitan hacer la distición entre los campos.
| type_name | el tipo de la estructura (struct o class) que contiene al Slink. |
| link_name | el nombre del campo del enlace doble dentro de la estructura. |
| using Aleph::DynArray_Set = typedef DynArray<T> |
Conjunto de elementos implantado mediante un arreglo dinámico.
DynArray_Set instrumenta un conjunto de elementos de tipo T.
El conjunto está internamente representado mediante un arreglo dinámico del tipo DynArray. Consecuentemente, el consumo en memoria es proporcional al número de elementos.
La inserción es sumamente rápida, la búsqueda es lineal y la eliminación de un elementpo ya encontrado también es muy rápida.
La clase recibe dos parámetros tipo: el tipo de elemento del conjunto y una clase de comparación cuyo único rol es determinar si un elemento es igual a no a otro.
Por razones de rapidez, se permite duplicar elementos.
| using Aleph::DynListStack = typedef DynList<T> |
Dynamic stack of generic elements of type T
DynListStack<T> models a dynamic stack based on single linked list.
| using GenericKeys = GenericItems<Container, T> |
Alias to GenricItems functor
| using Aleph::GenericKeys = typedef GenericItems<Container, T> |
Alias to GenricItems functor
| auto Aleph::shuffle | ( | const C< T > & | c | ) |
Randomly shuffle a sequence.
shuffle(c) produces a random permutation of container c
| [in] | c | container to be shuffled |
c
Here is the call graph for this function:| C<T*> Aleph::shuffle_ptr | ( | const C< T > & | c | ) |
Return a random sequence of pointers to items of a sequence.
| [in] | c | container to be shuffled |
c
Here is the call graph for this function: