Aleph-w  1.9
General library for algorithms and data structures
Sequences

Classes

struct  GenericTraverse< Container >
 
class  LocateFunctions< Container, Type >
 
struct  SpecialCtors< Container, T >
 
class  FunctionalMethods< Container, T >
 
struct  GenericItems< Container, T >
 
class  EqualToMethod< Container >
 
class  MapSequencesMethods< Container, Key, Data >
 
class  Aleph::BitArray
 
class  Aleph::Dlink::Iterator
 
class  Aleph::Dlink
 
class  Aleph::Filter_Iterator< Container, It, Show_Item >
 
class  Aleph::HTList
 
struct  Aleph::GenericTraverse< Container >
 
class  Aleph::LocateFunctions< Container, Type >
 
struct  Aleph::SpecialCtors< Container, T >
 
class  Aleph::FunctionalMethods< Container, T >
 
struct  Aleph::GenericItems< Container, T >
 
class  Aleph::EqualToMethod< Container >
 
class  Aleph::MapSequencesMethods< Container, Key, Data >
 
class  Aleph::DynList< T >::Iterator
 
class  Aleph::Slink
 
class  Aleph::Slink_Nc
 
struct  Aleph::Array< T >::Iterator
 
class  Aleph::Array< T >
 
struct  Aleph::ArrayQueue< T >::Iterator
 
class  Aleph::ArrayQueue< T >
 
struct  Aleph::FixedQueue< T >::Iterator
 
class  Aleph::FixedQueue< T >
 
class  Aleph::ArrayStack< T >::Iterator
 
class  Aleph::ArrayStack< T >
 
class  Aleph::FixedStack< T >::Iterator
 
class  Aleph::FixedStack< T >
 
class  Aleph::Dnode< T >::Iterator
 
class  Aleph::Dnode< T >
 
class  Aleph::Dyn_Slist_Nc< T >
 
class  Aleph::DynArray< T >::Iterator
 
class  Aleph::DynArray< T >
 
class  Aleph::DynDlist< T >::Iterator
 
class  Aleph::DynDlist< T >
 
struct  Aleph::DynListQueue< T >::Iterator
 
class  Aleph::DynListQueue< T >
 
class  Aleph::DynMatrix< T >
 
class  Aleph::DynSlist< T >::Iterator
 
class  Aleph::DynSlist< T >
 
struct  Aleph::MemArray< T >::Iterator
 
class  Aleph::MemArray< T >
 
struct  Aleph::Random_Set< T >::Iterator
 
class  Aleph::Random_Set< T >
 
class  Aleph::Slist< T >::Iterator
 
class  Aleph::Slist< T >
 
class  Aleph::Snode< T >
 

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)
 

Detailed Description

In Aleph-w ( $\aleph_\omega$) 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 ( $\aleph_\omega$) 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 ( $\aleph_\omega$) sequences:

  1. 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.

  2. Linked lists: the Aleph-w ( $\aleph_\omega$) doctrine is to export three levels of implementation:
    1. 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.

    2. 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.

    3. 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.

Author
Leandro Rabindranath León (lrleon en ula punto ve)

Macro Definition Documentation

◆ DLINK_TO_BASE

#define DLINK_TO_BASE (   type_name,
  link_name 
)
Value:
inline static type_name * dlink_to_base(Dlink * link) noexcept \
{ \
type_name * ptr_zero = 0; \
size_t offset_link = reinterpret_cast<size_t>(&(ptr_zero->link_name)); \
char * address_type = reinterpret_cast<char*>(link) - offset_link; \
return reinterpret_cast<type_name *>(address_type); \
}

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.

Parameters
type_namethe name of class of struct containing the Dlink field.
link_namethe name of Dlink field inside the class or struct

◆ DLINK_TO_TYPE

#define DLINK_TO_TYPE (   type_name,
  link_name 
)
Value:
inline static type_name * dlink_to_##type_name(Dlink * link) noexcept \
{ \
type_name * ptr_zero = 0; \
size_t offset_link = reinterpret_cast<size_t>(&(ptr_zero->link_name)); \
char * address_type = reinterpret_cast<char*>(link) - offset_link; \
return reinterpret_cast<type_name *>(address_type); \
}

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.

Parameters
type_namethe name of class or struct containing the Dlink field
link_namethe name of the Dlink field inside the class or struct.

◆ LINKNAME_TO_TYPE

#define LINKNAME_TO_TYPE (   type_name,
  link_name 
)
Value:
inline static type_name * link_name##_to_##type_name(Dlink * link) noexcept \
{ \
type_name * ptr_zero = 0; \
size_t offset_link = reinterpret_cast<size_t>(&(ptr_zero->link_name)); \
char * address_type = reinterpret_cast<char*>(link) - offset_link; \
return reinterpret_cast<type_name *>(address_type); \
}

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.

Note
You could have several 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.
Parameters
type_namethe name of struct or class containing to the Dlink object.
link_namethe name of Dlink field

◆ SLINK_TO_TYPE

#define SLINK_TO_TYPE (   type_name,
  link_name 
)
Value:
static type_name * slink_to_type(Slink * link) \
{ \
type_name * ptr_zero = 0; \
size_t offset_link = (size_t) &(ptr_zero->link_name); \
unsigned long address_type = ((unsigned long) link) - offset_link; \
return (type_name *) address_type; \
}

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:

  1. Registro * l1_to_type(Slink * link), la cual recibe un apuntador al campo l1 del registro y retorna el puntero al registro.
  2. Registro * l2_to_type(Slink * link), la cual recibe un apuntador al campo l2 del registro y retorna el puntero al registro.

La idea es disponer de esquemas de nombramiento que prmitan hacer la distición entre los campos.

Parameters
type_nameel tipo de la estructura (struct o class) que contiene al Slink.
link_nameel nombre del campo del enlace doble dentro de la estructura.

Typedef Documentation

◆ DynArray_Set

template<typename T , class Equal = Aleph::equal_to<T>>
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.

See also
DynArray

◆ DynListStack

template<typename T >
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.

See also
ArrayStack FixedStack

◆ GenericKeys [1/2]

template<class Container , typename T >
using GenericKeys = GenericItems<Container, T>

Alias to GenricItems functor

◆ GenericKeys [2/2]

template<class Container , typename T >
using Aleph::GenericKeys = typedef GenericItems<Container, T>

Alias to GenricItems functor

Function Documentation

◆ shuffle()

template<typename T , template< typename > class C>
auto Aleph::shuffle ( const C< T > &  c)

Randomly shuffle a sequence.

shuffle(c) produces a random permutation of container c

Parameters
[in]ccontainer to be shuffled
Returns
a shuffled permutation of c
+ Here is the call graph for this function:

◆ shuffle_ptr()

template<typename T , template< typename > class C>
C<T*> Aleph::shuffle_ptr ( const C< T > &  c)

Return a random sequence of pointers to items of a sequence.

Parameters
[in]ccontainer to be shuffled
Returns
a shuffled permutation of pointer to items in the sequence c
+ Here is the call graph for this function:

Leandro Rabindranath León