15 #ifndef NDEBUG // ==> Overview of File Translation ==> C++ 
   25 template <
class E> 
class Tree;
 
   26 template <
class E> 
bool check_ok( 
const E & );
 
   46     #ifdef USE_v_Alive // ==> NDEBUG ==> Overview of File Translation ==> C++ 
   47         static const unsigned N_Alive = 333; 
 
   49         static unsigned m_n_Alive; 
 
   92     unsigned Count() 
const ;
 
   95     friend bool check_ok<E>(
const Tree<E>& T);
 
  193     { 
return (
Tree&) *( 
reinterpret_cast<Tree*
> (&p)); }
 
  209     unsigned Tree::Tree_Node<E>::m_n_Alive = 0; 
 
  210     Tree::Tree_Node<E>* Tree::Tree_Node<E>::m_v_Alive[Tree::Tree_Node<E>::N_Alive]; 
 
  227         m_v_Alive[m_n_Alive] = p;
 
  252         if (m_root->m_refCount == 1) {
 
  255             m_root->m_refCount--;
 
  264     m_root->m_n_child = -1;
 
  265     m_root->m_left_child = 0;
 
  266     m_root->m_right_brother = 0;
 
  282             if ( m_root->m_refCount == 1 ) { 
 
  285                 m_root->m_refCount--;
 
  314             if ( m_root->m_refCount == 1 ) { 
 
  317                 m_root->m_refCount--;
 
  389             if ( 
unsigned(- child->
m_n_child) == n ) {
 
  395             if ( static_cast<unsigned>(child->
m_n_child) == n ) {
 
  397             } 
else if ( 
unsigned(child->
m_n_child) < n) {
 
  432     } 
else if ( -1 ==m_root->m_left_child->m_n_child ||
 
  433                  1 ==m_root->m_left_child->m_n_child ) {
 
  448     } 
else if ( 0 == m_root->m_left_child ) { 
 
  450     } 
else if ( -1 ==m_root->m_left_child->m_n_child ) {
 
  452     } 
else if ( 1 ==m_root->m_left_child->m_n_child ) {
 
  453         if ( -2 == m_root->m_left_child->m_right_brother->m_n_child  ||
 
  454               2 == m_root->m_left_child->m_right_brother->m_n_child ) {
 
  457     } 
else if ( 2 == m_root->m_left_child->m_n_child || -2 == m_root->m_left_child->m_n_child ) {
 
  479     unsigned n_child = m_root->Abs_n_child()-1; 
 
  480     if ( n_child <= 0 ) { 
 
  483     #ifdef ESTO_SOBRA_en_Left_Sibling 
  484         if (m_root->m_right_brother == 0)  { 
 
  500     if ( m_root == brother ) {
 
  507     return Tree( brother );
 
  524     } 
if (m_root->m_n_child < 0) { 
 
  527         return Tree( m_root->m_right_brother );
 
  541     return Sibling( -1 );
 
  556     if (m_root->m_n_child <= 0) { 
 
  563     if ( m_root->m_n_child == n_brother ) {
 
  570         if ( m_root->m_n_child + 1 == brother->
m_n_child ) {
 
  576         if ( m_root->m_n_child + 1 == - brother->
m_n_child ) {
 
  595     return ( m_n_child >= 0 ? 
unsigned(m_n_child) : 
unsigned( - m_n_child ) );
 
  628     } 
else if ( m_root->m_right_brother == 0 ) {
 
  640         unsigned abs_n = unsigned(-n);      
 
  641         if ( n_child < abs_n ) { 
 
  644             n_target = n_child - abs_n; 
 
  664             if ( 
unsigned(- brother->
m_n_child)  == n_target ) {
 
  671             if (n_child == n_target) { 
 
  673             } 
else if (n_child < n_target) { 
 
  702     return Tree( m_root->m_left_child ); 
 
  815     if ( (p==0) || (q==0)) { 
 
  832         if ( (p==0) || (q==0) ) { 
 
  838         if (! Comp0(p, q) ) {
 
  878     #ifdef NO_Implementado_para_evitar_forzar_que_el_valor_almacenado_tenga_su_metodo_OK 
  893     for (
unsigned i = 0; i < N; ++i) {
 
  929         m_root->m_left_child = 0;
 
  930         m_root->m_right_brother = 0;
 
  931         m_root->m_n_child = -1;
 
  956     if (m_root->m_left_child == 0) { 
 
  960         m_root->m_left_child = p;
 
  969     if ( n < n_brother ) { 
 
  976     } 
else if ( n == n_brother ) {
 
  992             } 
else if (
int(n) <  - brother->
m_n_child ) {
 
 1012             } 
else if ( brother->
m_n_child < 
int(n) ) {
 
 1043     unsigned n = Child_Number();
 
 1045         return Father().Change_Child( n-1, d );
 
 1070     if ( m_root->m_right_brother == 0 ) { 
 
 1075     if ( m_root->m_n_child < 0 ) { 
 
 1076         m_root->
m_n_child = - m_root->m_n_child; 
 
 1079         brother->
m_n_child = - ( m_root->m_n_child + 1 ); 
 
 1083         m_root->m_right_brother = brother;
 
 1089     int n_brother = m_root->m_right_brother->Abs_n_child();
 
 1090     if ( m_root->m_n_child + 1 == n_brother ) {
 
 1091         m_root->m_right_brother->m_data = d;
 
 1095         brother->
m_n_child = m_root->m_n_child + 1; 
 
 1099         m_root->m_right_brother = brother;
 
 1136         while ( child != 0 ) { 
 
 1155         for (
unsigned j = 0; j < Tree_Node<E>::N_Alive; ++j) {
 
 1161             for (
unsigned k = j; k < Tree_Node<E>::N_Alive-1; ++k) { 
 
 1167             for (
unsigned k = 0; k<3; ++j) { 
 
 1202             if ( m_root->m_n_child < 0 ) {
 
 1217     if ( m_root->m_refCount == 1 ) {
 
 1220         m_root->m_refCount--; 
 
 1221         m_root->m_n_child = -1; 
 
 1222         m_root->m_right_brother = 0; 
 
 1273         if ( n == n_child ) { 
 
 1281             m_root->m_left_child = 0;
 
 1285             if ( n > n_child ) {
 
 1298             if ( 
unsigned(- child->
m_n_child) == n ) { 
 
 1308             } 
else if ( 
unsigned(- child->
m_n_child) < n ) {
 
 1314         } 
else if ( 
unsigned(child->
m_n_child) == n ) {
 
 1328         } 
else if ( 
unsigned(child->
m_n_child) < n) {
 
 1408         if ( m_root->m_refCount == 1 ) { 
 
 1411             m_root->m_refCount--;
 
 1417         m_root = Copy_Deep0( o.
m_root );
 
 1418         m_root->m_n_child = -1; 
 
 1419         m_root->m_right_brother = 0;
 
 1420         m_root->m_refCount = 1;
 
 1460     if (m_root == o.
m_root) { 
 
 1463     #ifdef FALTA_verificar_en_Graft 
 1464         bool Ancestor( 
Tree & Child, 
Tree & Father );
 
 1465         assert( ! Ancestor( o, *
this ) ); 
 
 1472         Erase_Son_Prev(n, prev );
 
 1485     if ( o_father != m_root ) {
 
 1492         Erase_Son_Prev(n, prev );
 
 1495         unsigned o_n_child = o.
m_root->Abs_n_child();
 
 1496         if ( o_n_child == n ) { 
 
 1502         Erase_Son_Prev(n, prev );
 
 1506             if ( o.
m_root->m_right_brother == m_root ) { 
 
 1507                 o.
m_root->m_n_child = - int(n);
 
 1509                 o.
m_root->m_n_child = + int(n);
 
 1515     if (o_father != 0) { 
 
 1519             if ( o.
m_root->m_n_child < 0 ) { 
 
 1530             if ( o.
m_root->m_n_child < 0 ) { 
 
 1540         if ( m_root->m_left_child == 0 ) {
 
 1541             o.
m_root->m_right_brother = m_root; 
 
 1542             o.
m_root->m_n_child = - int(n);
 
 1543             m_root->m_left_child = o.
m_root;
 
 1545             o.
m_root->m_right_brother = m_root->m_left_child;
 
 1547             o.
m_root->m_n_child = + int(n);
 
 1548             m_root->m_left_child = o.
m_root;
 
 1554         if ( o.
m_root->m_right_brother == m_root ) {
 
 1556             o.
m_root->m_n_child = - int(n);
 
 1558             o.
m_root->m_n_child = + int(n);
 
Tree Previous_Sibling() const 
Sinónimo de Left_Sibling() 
 
Tree Left() const 
Sub-árbol izquierdo [en un árbol binario]. 
 
unsigned Size() const 
Usa Count() para retornar la cantidad de valores almacenados en el sub-árbol. 
 
Tree_Node(const value_type &d)
Constructor de vector. 
 
void NOT_null_pointer
Truco para usar el constructor que no verifica  (p != 0)  
 
friend bool operator!=(const Tree< X > &p, const Tree< X > &q)
¿¿¿ (p != q) ??? 
 
bool operator!=(const Tree< E > &p, const Tree< E > &q)
 
unsigned Count() const 
Retorna la cantidad de valores almacenados en el sub-árbol. 
 
Tree Father() const 
Acceso al padre. 
 
Tree & Copy(const Tree &o)
Copia superficial desde "o". 
 
E value_type
Nombre estándar del tipo de elemento contenido. 
 
friend bool operator==(const Tree< X > &p, const Tree< X > &q)
¿¿¿ (p == q) ??? 
 
static bool Comp0(const Tree_Node< E > *p, const Tree_Node< E > *q)
Compara recursivamente los árboles cuyos nodo raíz son "*p" y "*q". 
 
static void Erase0(Tree_Node< E > *p)
Elimina recursivamente a "*p" y a todos sus descendientes. 
 
unsigned Child_Number() const 
Retorna "n" si "*this" es el n-ésimo hijo de su padre, si no retorna 0 (cero) 
 
static Tree_Node< E > * Get_New(const value_type &d)
Crea un nuevo nodo y lo inicializa con "d". 
 
value_type & Data()
Valor almacenado en la raíz del sub-árbol. 
 
unsigned Count_Children() const 
Retorna la cantidad de hijos del árbol. 
 
friend bool check_ok(const Tree< E > &T)
Verifica que se cumpla la invariante de la clase, o sea, que el objeto esté bien construido. 
 
Tree Change_Left_Sibling_Inmediate(const value_type &d)
Sustituye por "d" el valor almacenado en el hermano inmediatamente anterior del sub-árbol. 
 
Tree Graft(unsigned n, Tree &o)
Injerta "o" para que sea el "n"-ésimo hijo de "*this". 
 
bool Is_Root() const 
Retorna "true" si el árbol no tiene padre. 
 
bool Equals(const Tree &o) const 
¿¿¿ (*this==o) ??? 
 
unsigned use_count() const 
Cantidad de referencias de la raíz del árbol. 
 
bool operator==(const Tree< E > &p, const Tree< E > &q)
 
Tree Change_Root(const value_type &d)
Sustituye por "d" el valor almacenado en la raíz del árbol. 
 
value_type m_data
Valor almacenado en el nodo. 
 
bool Same(const Tree &o) const 
Retorna true si "o" comparte la raíz con "*this". 
 
Tree Prev_Sibling() const 
Sinónimo de Left_Sibling() 
 
Tree & Move(Tree &o)
Traslada el valor de "o" a "*this". 
 
static Tree & CastTo_Sub_Tree_Ref(Tree_Node< E > *&p)
Convierte el puntero al nodo en un referencia a Tree. 
 
bool Is_Leaf() const 
Retorna "true" si el árbol es una hoja. 
 
void Erase()
Elimina el árbol y sus descendientes. 
 
Tree & Copy_Deep(const Tree &o)
Copia profunda de "o". 
 
Tree Right_Sibling() const 
Obtiene el hermano no vacío siguiente, que está hacia la derecha. 
 
unsigned Leftmost_N() const 
Retorna "n" si el hijo más izquierdo de "*this" es el n-ésimo hijo, si no retorna 0 (cero) ...
 
Tree Leftmost() const 
Obtiene el hijo más izquierdo del árbol. 
 
Tree Sibling(int n) const 
"n"-ésimo hermano a partir de "*this". 
 
const value_type & Data() const 
Valor almacenado en la raíz del sub-árbol. 
 
Tree Next_Sibling() const 
Sinónimo de Right_Sibling() 
 
bool Ok()
Usa check_ok(Tree& T) para verificar la invariante de Tree. 
 
Tree Change_Right_Sibling_Inmediate(const value_type &d)
Sustituye por "d" el valor almacenado en el hermano inmediatamente posterior del sub-árbol. 
 
Tree()
Constructor de vector. 
 
bool Empty() const 
Retorna "true" si el sub-árbol está vacío. 
 
value_type & operator*()
Valor almacenado en la raíz del sub-árbol. 
 
unsigned Abs_n_child() const 
Retorna el valor absoluto del campo "m_n_child". 
 
Tree_Node< E > * m_root
Un árbol "es" el puntero al nodo raíz. 
 
Tree Left_Sibling() const 
Obtiene el hermano no vacío anterior, que está hacia la izquierda. 
 
int m_n_child
Soy el el hijo número  "(m_n_child - 1)"  de mi padre. 
 
Tree & operator=(const Tree &o)
Sinónimo de this->Copy(o) 
 
Los métodos para trabajar con árboles regresan "referencias" que son sub-árboles. ...
 
Tree Right_Sibling_Inmediate() const 
Obtiene el hermano que está inmediatamente hacia la derecha. 
 
Tree(Tree_Node< E > *p)
Constructor a partir de un nodo. 
 
Tree Left_Sibling_Inmediate() const 
Obtiene el hermano que está inmediatamente hacia la izquierda. 
 
void Erase_Son(unsigned n)
Elimina el sub-árbol número "n". 
 
static void Count0(const Tree_Node< E > *p, unsigned &n)
Implementación recursiva para Count(). 
 
Tree Rightmost() const 
Obtiene el hijo más derecho del árbol. 
 
void Erase_Son_Prev(unsigned n, Tree_Node< E > *&)
Elimina el sub-árbol número "n-1" y retorna un puntero al nodo anterior al borrado. 
 
Tree_Node< E > * m_right_brother
Puntero al nodo hermano o al padre. 
 
Tree & operator=(const value_type &d)
Usa Change_Root() para sustituir por "d" el valor almacenado en la raíz del árbol. 
 
value_type * operator->()
Puntero al valor almacenado en la raíz del sub-árbol. 
 
unsigned m_refCount
Cantidad de punteros hacia mi. 
 
E value_type
Nombre estándar del tipo de elemento contenido. 
 
Nodos almacenados en el árbol. 
 
bool check_ok_Tree(Tree< E > &T)
Verifica que se cumpla la invariante de la clase, o sea, que el objeto esté bien construido. 
 
Tree_Node< E > * m_left_child
Puntero al nodo hijo más izquierdo. 
 
Tree Child(unsigned n) const 
Acceso al "n"-ésimo hijo. 
 
static Tree_Node< E > * Copy_Deep0(const Tree_Node< E > *p)
Hace una copia profunda nodo por nodo del árbol cuyo nodo raíz es "*p". 
 
Tree(NOT_null_pointer *p)
Constructor a partir de un nodo [ requiere  p != 0  ]. 
 
Tree & Swap(Tree &o)
Intercambia los valores de "*this" y "o". 
 
Tree Change_Child(unsigned n, const value_type &d)
Sustituye por "d" el valor almacenado en el hijo número "n" del árbol. 
 
Tree Right() const 
Sub-árbol derecho [en un árbol binario]. 
 
Tree Root() const 
Raíz del sub-árbol. 
 
unsigned Rightmost_N() const 
Retorna "n" si el hijo más derecho de "*this" es el n-ésimo hijo, si no retorna 0 (cero) ...