#include <tpl_dynSetTree.H>
Public Types | |
using | Node = typename Tree< Key, Compare >::Node |
using | Tree_Type = Tree< Key, Compare > |
typedef DynSetTree | Set_Type |
typedef Key | Item_Type |
typedef Key | Key_Type |
using | iterator = StlIterator< SetName > |
using | const_iterator = StlConstIterator< SetName > |
Public Member Functions | |
void | swap (DynSetTree &dset) |
DynSetTree (Compare cmp=Compare()) | |
Instancia un conjunto dinámico. | |
DynSetTree (const DynSetTree &srcTree) | |
Instancia un conjunto dinámico copia de srcTree. | |
Special_Ctors (DynSetTree, Key) | |
DynSetTree (DynSetTree &&srcTree) | |
void | empty () |
Elimina todos los elementos del conjunto. | |
DynSetTree & | operator= (const DynList< Key > &list) |
DynSetTree & | operator= (const DynSetTree &srcTree) |
Asigna a this el conjunto dinámico srcTree. | |
DynSetTree & | operator= (DynSetTree &&srcTree) |
Asigna a this el conjunto dinámico srcTree. | |
virtual | ~DynSetTree () |
Destructor; todos los elementos son liberados. | |
Key * | insert (const Key &key) |
Key * | insert (Key &&key) |
Key * | append (const Key &key) |
Key * | append (Key &&key) |
Key * | search_or_insert (const Key &key) |
Key * | search_or_insert (Key &&key) |
pair< Key *, bool > | contains_or_insert (const Key &key) |
pair< Key *, bool > | contains_or_insert (Key &&key) |
Key * | insert_dup (const Key &key) |
Key * | insert_dup (Key &&key) |
Key * | put (const Key &key) |
Key * | put (Key &&key) |
size_t | remove (const Key &key) |
Key | del (const Key &key) |
Key | remove_pos (const size_t i) |
bool | exist (const Key &key) const |
Retorna true si key pertenece al conjunto dinámico. | |
bool | has (const Key &key) const |
bool | contains (const Key &key) const |
Key & | find (const Key &key) const |
std::pair< int, Key * > | find_position (const Key &key) const |
Key * | search (const Key &key) const |
const Key & | min () const |
const Key & | get_first () const |
const Key & | max () const |
const Key & | get_last () const |
const Key & | get () const |
Sinónimo de max. | |
const size_t & | size () const |
Retorna la cardinalidad del conjunto. | |
bool | is_empty () const |
Retorna true si el conjunto está vacÃo. | |
size_t | internal_path_length () const |
Node * | get_root_node () const |
const Key & | get_root () const |
const Key & | get_item () const |
Retorna un elemento cualquiera del conjunto. | |
size_t | height () const |
Calcula y retorna la altura del árbol binario de búsqueda. | |
template<class Op > | |
void | for_each_in_preorder (void(*visitFct)(Node *, int, int)) |
long | position (const Key &key) const |
Key & | select (const size_t &i) |
const Key & | select (const size_t &i) const |
Key & | operator() (const size_t &i) |
const Key & | operator[] (const Key &key) const |
const Key & | operator[] (const Key &key) |
Key & | access (const size_t &i) |
bool | verify () |
template<class Key_Op > | |
void | for_each_preorder (Key_Op &key_op) const |
template<class Key_Op > | |
void | for_each_preorder (Key_Op &&key_op=Key_Op()) const |
template<class Key_Op > | |
void | for_each_inorder (Key_Op &key_op) const |
template<class Key_Op > | |
void | for_each_inorder (Key_Op &&key_op=Key_Op()) const |
template<class Key_Op > | |
void | for_each_postorder (Key_Op &key_op) |
template<class Key_Op > | |
void | for_each_postorder (Key_Op &&key_op=Key_Op()) |
DynSetTree & | join (DynSetTree &t, DynSetTree &dup) |
DynSetTree & | join (DynSetTree &t, DynSetTree &&dup=DynSetTree()) |
DynSetTree & | join_dup (DynSetTree &t) |
bool | split_key (const Key &key, DynSetTree &l, DynSetTree &r) |
void | split_pos (const size_t pos, DynSetTree &l, DynSetTree &r) |
void | split_key_dup (const Key &key, DynSetTree &l, DynSetTree &r) |
template<class Operation > | |
bool | traverse (Operation &op) |
template<class Operation > | |
bool | traverse (Operation &&op=Operation()) |
template<class Operation > | |
bool | traverse (Operation &op) const |
template<class Operation > | |
bool | traverse (Operation &&op=Operation()) const |
auto | get_it () const |
auto | get_it (size_t pos) const |
auto | get_itor () const |
Key & | nth_ne (const size_t n) noexcept |
const Key & | nth_ne (const size_t n) const noexcept |
Key & | nth (const size_t n) |
const Key & | nth (const size_t n) const |
Key * | find_ptr (Operation &operation) noexcept(noexcept(operation)) |
const Key * | find_ptr (Operation &operation) const noexcept(noexcept(operation)) |
const Key * | find_ptr (Operation &&operation) const noexcept(noexcept(operation)) |
Key * | find_ptr (Operation &&operation) noexcept(noexcept(operation)) |
size_t | find_index (Operation &operation) const noexcept(noexcept(operation)) |
size_t | find_index (Operation &&operation) const noexcept(noexcept(operation)) |
std::tuple< bool, Key > | find_item (Operation &operation) noexcept(noexcept(operation)) |
std::tuple< bool, Key > | find_item (Operation &operation) const noexcept(noexcept(operation)) |
std::tuple< bool, Key > | find_item (Operation &&operation) noexcept(noexcept(operation)) |
std::tuple< bool, Key > | find_item (Operation &&operation) const noexcept(noexcept(operation)) |
void | emplace (Args &&... args) |
void | emplace_end (Args &&... args) |
void | emplace_ins (Args &&... args) |
size_t | ninsert (Args ... args) |
size_t | nappend (Args ... args) |
void | for_each (Operation &operation) noexcept(noexcept(operation)) |
void | for_each (Operation &operation) const noexcept(noexcept(operation)) |
void | for_each (Operation &&operation) const noexcept(noexcept(operation)) |
void | for_each (Operation &&operation) noexcept(noexcept(operation)) |
void | each (Operation &operation) noexcept(noexcept(operation)) |
void | each (Operation &operation) const noexcept(noexcept(operation)) |
void | each (Operation &&operation) const noexcept(noexcept(operation)) |
void | each (Operation &&operation) noexcept(noexcept(operation)) |
void | each (size_t pos, size_t slice, Operation &operation) const |
void | each (size_t pos, size_t slice, Operation &&operation) const |
void | mutable_for_each (Operation &operation) noexcept(noexcept(operation)) |
void | mutable_for_each (Operation &&operation) noexcept(noexcept(operation)) |
bool | all (Operation &operation) const noexcept(noexcept(operation)) |
bool | all (Operation &&operation) const noexcept(noexcept(operation)) |
bool | exists (Operation &op) const noexcept(noexcept(op)) |
bool | exists (Operation &&op) const noexcept(noexcept(op)) |
DynList< __T > | maps (Operation &op) const |
DynList< __T > | maps (Operation &&op) const |
DynList< __T > | maps_if (Prop prop, Operation &op) const |
DynList< __T > | maps_if (Prop prop, Operation &&op) const |
DynList< Key > | to_dynlist () const |
__T | foldl (const __T &init, Op &op) const noexcept(noexcept(op)) |
__T | foldl (const __T &init, Op &&op=Op()) const noexcept(noexcept(op)) |
Key | fold (const Key &init, Operation &operation) const noexcept(noexcept(operation)) |
Key | fold (const Key &init, Operation &&operation) const noexcept(noexcept(operation)) |
DynList< Key > | filter (Operation &operation) const |
DynList< Key > | filter (Operation &&operation) const |
DynList< const Key *> | ptr_filter (Operation &operation) const |
DynList< const Key *> | ptr_filter (Operation &&operation) const |
DynList< std::tuple< Key, size_t > > | pfilter (Operation &operation) const |
DynList< std::tuple< Key, size_t > > | pfilter (Operation &&operation) const |
std::pair< DynList< Key >, DynList< Key > > | partition (Operation &op) const |
std::pair< DynList< Key >, DynList< Key > > | partition (Operation &&op) const |
std::pair< DynList< Key >, DynList< Key > > | partition (size_t n) const |
std::tuple< DynList< Key >, DynList< Key > > | tpartition (Operation &op) const |
std::tuple< DynList< Key >, DynList< Key > > | tpartition (Operation &&op) const |
size_t | length () const noexcept |
DynList< Key > | rev () const |
DynList< Key > | take (const size_t n) const |
DynList< Key > | take (size_t i, size_t j, size_t step=1) const |
DynList< Key > | drop (const size_t n) const |
void | mutable_drop (size_t n) |
DynList< T > | items () const |
DynList< T > | keys () const |
bool | equal_to (const DynSetTree< Key, Tree, Compare > &r) const noexcept |
bool | operator== (const DynSetTree< Key, Tree, Compare > &r) const noexcept |
bool | operator!= (const DynSetTree< Key, Tree, Compare > &r) const noexcept |
Negation of are_equal() | |
iterator | begin () noexcept |
const_iterator | begin () const noexcept |
iterator | end () noexcept |
const_iterator | end () const noexcept |
const_iterator | cbegin () const noexcept |
const_iterator | cbegin () noexcept |
const_iterator | cend () const noexcept |
const_iterator | cend () noexcept |
Conjunto dinámico de elementos de tipo genérico T implementado mediante una clase de árboles binarios.
DynSetTree define una tabla de elementos de tipo Key que está instrumentada con la clase de árbol binario de búsqueda Tree<Key> y ordenado mediante el criterio Compare()().
using Aleph::DynSetTree< Key, Tree, Compare >::Node = typename Tree<Key, Compare>::Node |
Tipo de nodo binario empleado por el árbol binario de búsqueda interno.
|
inlinenoexceptinherited |
Check if all the elements of container satisfy a condition.
all(operation)
checks if for each element item
of container operation(item)
returns true
.
This method has complexity in average and worst case.
[in] | operation | to be used as condition |
true
if all the elements satisfy the criteria: false
otherwise. anything | that could throw operation |
|
inlinenoexceptinherited |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
inline |
Deletes key
and returns a full copy of stored key
This method is intended to be used with compound keys, by example pairs, whose searching is done by a particular member of compound data.
[in] | key | key to be removed |
domain_error | if the key is not found in the set |
|
inlineinherited |
Drop the first n elements seen in the container during its traversal.
The complexity of this method is where N always is the number of elements of container.
DynList<T>
having the remainder elements according to traversal order. bad_alloc | if there is no enough memory or out_of_range if n is greater or equal than N (the number of elements in the container). |
|
inlinenoexceptinherited |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
inlinenoexceptinherited |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
inlinenoexceptinherited |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
inlinenoexceptinherited |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
inlineinherited |
Traverse all the container and performs a mutable operation on each element.
mutable_for_each(operation)
traverses the container and on each element item
is performed operation(item)
.
operation
could have the following signature:
void operation(T & item)
Be very careful with the fact that this method allows to modify the elements themselves, what could badly alter the internal state of container. This would be the case for heaps, binary trees and hash tables.
[in] | <tt>operation</tt> | to be done on each element. |
this
anything | that can throw operation |
|
inlineinherited |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
inlineinherited |
Appends a new element into the container by constructing it in-place with the given args.
emplace(args)
tries to match a constructor T(args)
. If this exists, then this is constructed in-place and directly forwarded to the method append() of container. If all on the container and
T` is adequately done, then the object is constructed once time, successively forwarded and at its target place in the container is moved, avoiding thus unnecessary copies.
append()
is equivalent to insert()
.[in] | args | variadic arguments list |
bad_alloc | if there is no enough memory |
|
inlineinherited |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
inlineinherited |
Insert a new element into the container by constructing it in-place with the given args.
emplace_ins(args)
tries to match a constructor T(args)
. If this exists, then this is constructed in-place and directly forwarded to the method insert() of container. If all on the container and
T` is adequately done, then the object is constructed once time, successively forwarded and finally, at its target place in the container, is moved, avoiding thus unnecessary copies.
insert()
depends of container. In general, this has some sense for lists and arrays and it means insertion at the beginning of sequence. On other type of container append()
is equivalent to insert()
.[in] | args | variadic arguments list |
bad_alloc | if there is no enough memory |
|
inlinenoexceptinherited |
Test if elements of this
are exactly contained in another container.
This method serves for testing if two containers contain the same elements. First, the container sizes are tested for equality. If they have the same size, then the testing is done by traversing this
. Each seen element is searched in the another container with the method search()
. So the container r
must export the search()
method, which frequently is the case for containers oriented to fast retrieval.
DynList
, the size is computed, not retrieved. So take in account this fact.[in] | r | container on which the searches will be performed. |
true
if the container have the same size and all the elements of this
are present in r
|
inlinenoexceptinherited |
Test for existence in the container of an element satisfying a criteria.
exists(op)
returns true
if it exists any element item
in container for which op(item)
return true
.
This method has complexity in average and worst case.
[in] | op | operation for testing existence |
true
if it exists an item for which op
return true; false
otherwise. anything | that could throw op |
|
inlinenoexceptinherited |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
inlineinherited |
Filter the elements of a container according to a matching criteria.
This method builds a dynamic list with copies of items of container matching a criteria defined by operation
, which should have the following signature:
bool operation(const T & item)
If operation
return true
then item
matches the criteria; otherwise, operation
must return false
.
For example, if the container has integer, the the following code snippet would return a list containing the items greater than 100:
c.filter([] (auto item) { return item > 100; });
[in] | operation | defining the flter criteria |
DynList<T>
with the matched elements. anything | that could throw operation or bad_alloc if there is no enough memory |
|
inlineinherited |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
inline |
Retorna una referencia modificable a un elemento dentro del conjunto.
find(key) busca la clave key en el conjunto y retorna una referencia modificable hacia el valor contenido en el conjunto.
[in] | key | clave a buscar. |
domain_error | si key no está dentro del conjunto. |
|
inlinenoexceptinherited |
Find the position of an item in the container according to a searching criteria.
find_index(operation)
traverses the container and on each item perform operation(item)
. If the result of operation
is true
, then the traversal is stopped and the position of the current item (which mathes operation
) is returned.
operation
must have the following signature:
bool operation(const typename Container::Item_Type & item)
[in] | <tt>operation</tt> | to be performed on each item for matching a searching criteria. |
|
inlinenoexceptinherited |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
inlinenoexceptinherited |
Safe sequential searching of an item matching a criteria.
find_item(operation)
traverses the container and on each item perform operation(item)
. If the result of operation
is true
, then the traversal is stopped and duple containg a copy of found item is returned.
The method is said safe because returns a copy of item.
operation
must have the following signature:
bool operation(const typename Container::Item_Type & item)
[in] | <tt>operation</tt> | to be used as searching criteria |
false
and the second is the result of default constructor on the type stored in the container.
|
inlinenoexceptinherited |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
inlinenoexceptinherited |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
inlinenoexceptinherited |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
inline |
Retorna la posición infija (ordenada) de la clave key o lo que seria su posición de pertenecer al árbol.
find_position(key) busca en el árbol extendido la clave key (lo cual toma tiempo ) y retorna la posición infija del nodo que contiene la clave.
[in] | key | clave a buscar y a determinar posición infija. |
|
inlinenoexceptinherited |
Find a pointer to an item in the container according to a searching criteria.
find_ptr(operation)
traverses the container and on each item perform operation(item)
. If the result of operation
is true
, then the traversal is stopped and a pointer to the current item (which mathes operation
) is returned.
operation
must have the following signature:
bool operation(const typename Container::Item_Type & item)
[in] | <tt>operation</tt> | to be performed on each item for matching a searching criteria. |
nullptr
otherwise.
|
inlinenoexceptinherited |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
inlinenoexceptinherited |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
inlinenoexceptinherited |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
inlinenoexceptinherited |
Simplified version of foldl() where the folded type is the same type of elements stored in the container.
|
inlinenoexceptinherited |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
inlinenoexceptinherited |
Fold the elements of the container to a specific result.
foldl(init, op)
set an internal variable acc
of type __T
to init
value. Then it traverses the container and on each item
it performs:
acc = op(acc, op(acc, item);
So acc
serves as a sort of accumulator.
op
should have the following signature:
__T op(__T acc, const T & item);
Since foldl
is overloaded with several operation structures, there is a certain flexibility with the parameter qualifiers. You could, for example, to declare acc
and/or item
by value.
The method is a template. The first template parameter __T
specifies the final folded type. By default, this type is T
(the type of elements stored in the container). The second parameter is the operation. If the folded type is the same than T
(the type of item stored), the you can simply write a foldl()
. For example, if the container stores integer, in order to determine the maximum of all elements you could do:
c.foldl(std::numeric_limits<int>::min(), [] (int acc, int item) { return std::min(acc, item); });
When the folded type is different than T
, then you must specify the folded type as template parameter. For example, if you want to compute the sum of inversed elements, the you could do it as follows:
c.template foldl<double>(0, [] (double acc, int item) { return acu + 1.0/item; });
[in] | init | initial value of folded value (or accumulator). |
[in] | op | operation to be performed on each item and used for folding. |
anything | that could throw op |
|
inlinenoexceptinherited |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
inlinenoexceptinherited |
Traverse all the container and performs an operation on each element.
for_each(operation)
traverses the container and on each element item
is performed operation(item)
.
operation
must have the following signature:
void operation(const T & item)
Overloadings of this method allow that that the signature can be lightly different; for example, remove the reference or the const
.
[in] | <tt>operation</tt> | to be done on each element. |
this
anything | that can throw operation |
|
inlinenoexceptinherited |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
inlinenoexceptinherited |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
inlinenoexceptinherited |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
inline |
Efectúa un recorrido prefijo sobre todas los nodos del árbol e invoca la operación visitFct
en cada visita
|
inline |
Efectúa un recorrido infijo sobre todas las claves del conjunto e invoca la operacion Op.
Op(p)
tiene la siguiente estructura:
[in] | key_op | operación a ejecutar sobre cada clave |
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
inline |
Efectúa un recorrido sufijo sobre todas las claves del conjunto e invoca la operacion Op.
Op(p)
tiene la siguiente estructura:
[in] | key_op | operación a ejecutar sobre cada clave |
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
inline |
Efectúa un recorrido prefijo sobre todas las claves del conjunto e invoca la operacion Op.
Op(p)
tiene la siguiente estructura:
[in] | key_op | operación a ejecutar sobre cada clave |
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
inlineinherited |
Return an properly initialized iterator positioned at the first item on the container
|
inlineinherited |
Return an properly initialized iterator positioned at the pos
item on the container
|
inlineinherited |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
inline |
Inserta una clave en el conjunto dinámico.
Inserta la clave key en el conjunto dinámico.
[in] | key | clave a insertar. |
|
inline |
Calcula y retorna la longitud del camino interno del árbol binario de búsqueda.
|
inlineinherited |
Return a list of all the elements of a container sorted by traversal order.
DynList<T>
containing all the elements of the container bad_alloc | if there is no enough memory |
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
inlineinherited |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
inlinenoexceptinherited |
Count the number of elements of a container.
This method counts the number of elements stored in the container.
size()
|
inlineinherited |
Map the elements of the container.
maps(op)
produces a dynamic list resulting of mapping of each element of container item
to the result of operation op(item)
.
maps()
is a template method which receives as template parameters the type __T
, which is the type of target or range of mapping, and the transforming operation. By default __T
is the same type of the elements stored in the container.
operation
should have the following signature:
__T operation(const T & item)
So, operation(item)
performs a transformation of item
towards the type __T
.
If __T ==
T`, which is common and by default, then you could specify a mapping without need of template specification. For example, if the container has integer values, the a mapping of item multiplied by 4 could be very simply written as follows:
c.maps([] (int item) { return 4*i; });
In contrast, if the range type is different than the domain type, then it is necessary to specify the template
keyword in the method call. For example, if the range is double
and you want to return the elements divided by 4, the could do as follows:
c.template maps<double>([] (int item) { return 1.0*item/4; });
[in] | op | operation to be performed in order to do the transformation on an item |
anything | that could throw op or bad_alloc if there is no enough memory |
|
inlineinherited |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
inlineinherited |
Conditional mapping of the elements of the container.
maps_if(prop, op)
traverses each item of container, on each item it tests the proposition prop
. If this last is true, then the item is mapped through the function op(item)
.
[in] | op | operation to be perfomed in order to do the transformation on an item . |
[in] | prop | a lambda returning a bool which perform the logical test. |
anything | that could throw op or bad_alloc if there is no enough memory |
|
inlineinherited |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
inline |
Retorna la mayor clave contenida en el conjunto según el criterio de comparación dado.
|
inline |
Retorna la menor clave contenida en el conjunto según el criterio de comparación dado.
|
inlineinherited |
Drop the first n elements seen from container.
The complexity of this method is where N always is the number of elements of container.
out_of_range | if n is greater or equal than N (the number of elements in the container). |
|
inlinenoexceptinherited |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
inlineinherited |
Append n variadic items
[in] | args | items to be appended |
|
inlineinherited |
Insert n variadic items
[in] | args | items to be inserted |
|
inlineinherited |
Return the n-th item of container.
The notion of ordinal depends of type of container. On list, probably will be the insertion order. On binary search trees will be the nth smaller item. On hash tables will be pseudo random.
[in] | n | the nth item to find |
out_of_range | if n is greater or equal that the size of container. |
|
inlineinherited |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
inlinenoexceptinherited |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
inlinenoexceptinherited |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
inlineinherited |
Exclusive partition of container according to a filter criteria.
partition(op)
traverses the container and filters its elements according to the filter criteria defined by op
. The filtered elements are copied to a first list and the not filtered ones to a second list. When all the container is traversed, a pair containing these lists is returned.
The op
requirements are the same than for filter()
.
[in] | op | operation instrumenting the filter criteria |
std::pair<DynList<T>, DynList<T>>.
firstcontains the filtered elements and
secondthe non-filtered ones. \throw anything that could throw op or
bad_alloc` if there is no enough memory
|
inlineinherited |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
inlineinherited |
Exclusive partition of container in the nth item
partition(n)
traverses the container and produces a pair of lists. The first one contains the first n
elements and the second one the this->size() - n
remaining elements.
[in] | n | the first n items of the first list |
anything | that could throw op or bad_alloc if there is no enough memory |
|
inlineinherited |
Filter the elements of a container according to a matching criteria and determine its positions respect to the traversal of container.
pfilter(operation)
is very similar to filter()
, but instead of building a list of filtered elements, it builds a list of pairs with form (item, pos)
, where item
is a copy of filtered element and pos
is its position respect to the traversal order. The position is relative to the container type.
The pair is defined with a tuple:
std::tuple<T, size_t>
[in] | operation | that defines the filter criteria |
bad_alloc | if there is no enough memory |
|
inlineinherited |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
inline |
Retorna la posición infija (ordenada) de la clave key.
position(key) busca en el treap extendido la clave key (lo cual toma tiempo ) y retorna la posición infija del nodo que contiene la clave.
[in] | key | clave a buscar y a determinar posición infija. |
|
inlineinherited |
Filter the elements of a container according to a matching criteria an return pointer to the matched items in the container.
This method builds a dynamic list with stores pointers to the items of matching a criteria defined by operation
, which should have the followgin signature:
bool operation(const T & item)
If operation
return true
then item
matches the criteria; otherwise, operation
must return false
.
For example, if the container has integer, the the following code snippet would return a list containing the items greater than 100:
c.ptr_filter([] (auto item) { return item > 100; });
[in] | operation | defining the flter criteria |
DynList<const T*>
with the pointers to the matched elements. anything | that could throw operation or bad_alloc if there is no enough memory |
|
inline |
Elimina una clave del conjunto dinámico.
remove(key) busca la clave key del conjunto y la elimina.
[in] | key | clave a eliminar |
|
inline |
Elimina una clave del conjunto dinámico.
remove(key) busca la clave key del conjunto y la elimina.
[in] | key | clave a eliminar |
|
inlineinherited |
Return a list with the elements of container in reverse order respect to its traversal order.
DynList<T>
inversely ordered accordirg to the traversal order. bad_alloc | if there is no enough memory |
|
inline |
Busca un elemento en el conjunto.
search(key) busca la clave key en el conjunto. Si el elemento se encuentra en el conjunto, entonces se retorna un puntero al valor contenido en el conjunto; de lo contrario se retrona nullptr.
[in] | key | clave a buscar. |
|
inline |
Busca la clave key
en el árbol binario de búsqueda o lo inserta en caso de no encontrarse.
search_or_insert(key)
busca en el árbol binario un nodo cuya clave sea KEY(p)
. Si la clave se encuentra, entonces se retorna un puntero a ella; de lo contrario se inserta key
en el árbol binario de búsqueda this.
[in] | key | la clave a buscar o insertar. |
|
inline |
Retorna el i-ésimo nodo en posición infija
[in] | i | posición deseada |
|
inline |
Particiona el árbol binario de búsqueda según una clave.
split_key(key,l,r) particiona, según la clave key, el árbol binario de búsqueda this en dos árboles l y r. Luego de la operación el árbol this deviene vacÃo, l contiene todas las claves menores que key y r las mayores.
[in] | key | clave de partición. |
[out] | l | árbol con las claves menores que key. |
[out] | r | árbol con las claves mayores que key. |
|
inline |
Particiona el árbol binario de búsqueda según una clave que puede estar presente en el árbol.
split_dup(key,l,r) particiona, según la clave key, el árbol binario de búsqueda this en dos árboles l y r. Luego de la operación el árbol this deviene vacÃo, l contiene todas las claves menores que key y r las mayores o iguales.
[in] | key | clave de partición. |
[out] | l | árbol con las claves menores que key. |
[out] | r | árbol con las claves mayores o iguales que key. |
|
inline |
Particiona el árbol binario de búsqueda según una posición infija.
split_pos(pos,l,r) particiona árbol binario de búsqueda this en dos árboles l y r. Luego de la operación el árbol this deviene vacÃo, l contiene las pos primeras claves y r las restantes.
[in] | pos | posición de partición |
[out] | l | árbol con las claves entre intervalo [0,pos] |
[out] | r | árbol con las claves en el intervalo (pos,N), donde N es el número de claves |
|
inline |
Intercambia todos los elementos del treap this con el treap tree en tiempo contante (y extremadamente rápido).
[in] | tree | el treap a intercambiar con this |
|
inlineinherited |
Return a list with the first n elements seen in the container during its traversal.
The complexity of this method is where n can be less than the number of elements of container.
DynList<T>
having the first n
elements according to its traversal order. bad_alloc | if there is no enough memory or out_of_range if n is greater or equal than the number of elements in the container. |
|
inlineinherited |
Return a list with elements seen in the container between i and j position respect to its traversal.
The complexity of this method is where n can be less than the number of elements of container.
DynList<T>
having the first n
elements according to its traversal order. bad_alloc | if there is no enough memory or out_of_range if n is greater or equal than the number of elements in the container. |
|
inlineinherited |
Exclusive partition of container according to a filter criteria.
This methos has exactly the same semantic than partition(Operation & op)
, excepts than instead of returning a std::pair
it returns a std::tuple
.
[in] | op | operation instrumenting the filter criteria |
std::tuple<DynList<T>, DynList<T>>.
firstcontains the filteres elements and
secondthe non-filtered ones. \throw anything that could throw op or
bad_alloc` if there is no enough memory
|
inlineinherited |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
|
inline |
Traverse all the set of pairs and for each key executes the operation op.
Operation must have the signature
If
returns false then the traversal is aborted; otherwise the the routine advance and so on
[in] | operation |