示例#1
0
bool ArbolB<g>::insert(int valor){
	Nodo *aux = raiz;
	while(aux){
		if(!aux->tieneHijos()){
			if(aux->insert(valor)){
				rebalancear(aux);
				++n;
				return true;
			}else return false;
		}else {
			aux = aux->getSon(valor);
			if(!aux) return false;
		}
	}
	raiz = new (nothrow) Nodo(valor, NULL);
	if(!raiz) throw NoHayMemoria();
	++n;
	return true;
}
示例#2
0
文件: v35a.cpp 项目: sergiojx/myrepo
Nodo* NodoInterno::insert(Datos *otrosDatos)
{
	//es el valor del nuevo opjeto Datos mas grnade o mas pequeño que el propio??
	int resultado = datos->comparar(*otrosDatos);

	switch (resultado)
	{
		case igual:
		case mayor:
		{
					  NodoInterno *datosNodo = new NodoInterno(otrosDatos, this);
					  return datosNodo;
		}
		break;
		case menor:
		{
					  siguiente = siguiente->insert(otrosDatos);
					  return this;
		}
		break;
	}
	return this;
}
示例#3
0
文件: v35a.cpp 项目: sergiojx/myrepo
Nodo * NodoHead::insert(Datos *datos)
{
	siguiente = siguiente->insert(datos);
	return this;
}