public void AgregarElemento(int x, int level, float xPos, float yPos, float xscale, float yscale, int pos) { if (raiz == null) { if (position.ContainsKey(level)) { raiz = new NodoABB(); raiz.info = x; raiz.level = level; raiz.x = position[level][pos - 1]; raiz.y = yPos; raiz.xscale = xscale; raiz.yscale = yscale; raiz.hijoIzq = new ABB(); raiz.hijoIzq.InicializarArbol(); raiz.hijoDer = new ABB(); raiz.hijoDer.InicializarArbol(); } } else if (raiz.info > x) { level++; pos *= 2; pos--; raiz.hijoIzq.AgregarElemento(x, level, xPos - 100f - 50f * level, yPos + 64f, 1f, 1f, pos); } else if (raiz.info < x) { level++; pos *= 2; raiz.hijoDer.AgregarElemento(x, level, xPos + 100f + 50f * level, yPos + 64f, 1f, 1f, pos); } }
public void EliminarElem(int x) { if (raiz != null) { if (raiz.info == x && raiz.hijoIzq.ArbolVacio() && raiz.hijoDer.ArbolVacio()) { raiz = null; } else if (raiz.info == x && !raiz.hijoIzq.ArbolVacio()) { raiz.info = mayor(raiz.hijoIzq); raiz.hijoIzq.EliminarElem(raiz.info); } else if (raiz.info == x && raiz.hijoIzq.ArbolVacio()) { raiz.info = menor(raiz.hijoDer); raiz.hijoDer.EliminarElem(raiz.info); } else if (raiz.info < x) { raiz.hijoDer.EliminarElem(x); } else { raiz.hijoIzq.EliminarElem(x); } } }
public void AddNode(int value, NodoABB nodoPadre) { throw new NotImplementedException(); }
public void InicializarArbol() { raiz = null; }