Ejemplo n.º 1
0
        public void Inserir(string hashtag, long end)
        {
            NodeArvore NewNode = new NodeArvore();

            NewNode.sethashtag(hashtag);
            if (Root.getAnterior == null && raiz.gethashtag == null)
            {
                raiz.sethashtag(hashtag);
                raiz.addList(end);
                raiz.setDireita(null);
                raiz.setEsquerda(null);
            }
            else
            {
                NodeArvore aux = BuscarInsercao(hashtag, end);
                if (aux == null)
                {
                    Console.Beep();
                }
                else
                {
                    if (hashtag.CompareTo(aux.gethashtag) > 0)
                    {
                        aux.setDireita(NewNode);
                        NewNode.setAnterior(aux);
                    }
                    else
                    {
                        aux.setEsquerda(NewNode);
                        NewNode.setAnterior(aux);
                    }
                }
            }
            quantidade++;
        }
Ejemplo n.º 2
0
        public void PrintArvore(NodeArvore node)
        {
            LinkedList <string> vs = new LinkedList <string>();

            NodeArvore aux;
            NodeArvore aux1;

            vs.AddLast(node.gethashtag);
            aux = node.getEsquerda;
            //aux1 = node.getDireita;

            do
            {
                vs.AddLast(aux.gethashtag);
                aux = node.getEsquerda;
            } while (aux != null);

            foreach (var item in vs)
            {
                Console.WriteLine(item);
            }
        }
Ejemplo n.º 3
0
        public NodeArvore Busca(NodeArvore node, string hashtag)
        {
            if (node == null)
            {
                Console.WriteLine("Não Achei! " + hashtag);
                return(null);
            }
            else
            {
                if (hashtag.CompareTo(node.gethashtag) == 0)
                {
                    FileStream binary = new FileStream(Environment.CurrentDirectory + @"\main.dat", FileMode.Open);

                    byte[] mens = new byte[2000];
                    string aux, fim;

                    foreach (var end in node.end_)
                    {
                        binary.Seek(end, SeekOrigin.Begin);
                        binary.Read(mens, 0, 620);
                        aux = new string(Encoding.UTF8.GetChars(mens));
                        fim = aux.Substring(0, 516);
                        Console.WriteLine(fim);
                    }
                    binary.Close();
                }
                else if (hashtag.CompareTo(node.gethashtag) < 0)
                {
                    Busca(node.getEsquerda, hashtag);
                }
                else
                {
                    Busca(node.getDireita, hashtag);
                }
            }
            return(null);
        }
Ejemplo n.º 4
0
 public void setEsquerda(NodeArvore no)
 {
     esquerda = no;
 }
Ejemplo n.º 5
0
 public void setDireita(NodeArvore no)
 {
     direita = no;
 }
Ejemplo n.º 6
0
 public void setAnterior(NodeArvore no)
 {
     anterior = no;
 }