Skip to content

Conversation

@nahuel1114
Copy link

No description provided.

GabrielEValenzuela and others added 3 commits April 2, 2025 20:15
Se implementaron los metodos faltantes en queue y stack. Se crearon los archivos .cpp de list, queue y stack.
Se implementaron metodos print() en queue y stack, tambien metodos registerDecision y onNewEvent en clase Engine. Se agregaron comandos de consola para CHECK_EVENT, SHO_EVENT y SHOW_HISTORY. Se creo un struct Event para registrar los eventos del jugador.
@GabrielEValenzuela GabrielEValenzuela changed the base branch from pila_cola to master April 7, 2025 23:56
Copy link
Owner

@GabrielEValenzuela GabrielEValenzuela left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GJ!

Comment on lines +18 to +22
add_executable(${CMAKE_PROJECT_NAME} ${SRC_FILES}
src/queue.cpp
src/stack.cpp
src/list.cpp
include/event.h)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Esto es redundante, la línea 15 ya lo hace :)

Comment on lines +62 to +65
bool Stack<TData>::isEmpty() const
{
return m_top == nullptr;
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
bool Stack<TData>::isEmpty() const
{
return m_top == nullptr;
}
bool Stack<TData>::isEmpty() const
{
return m_size == 0;
}

// Created by nahue on 5/4/2025.
//

#include "../include/dataStructures/queue.hpp"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#include "../include/dataStructures/queue.hpp"
#include "dataStructures/queue.hpp"

current = current->next;
}
std::cout << "nullptr" << std::endl;
} No newline at end of file

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Falta un salto de línea aquí

EXPECT_EQ(s.size(), 3);
s.pop();
EXPECT_EQ(s.size(), 2);
} No newline at end of file

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aqui

EXPECT_EQ(q.getSize(), 2);
q.dequeue();
EXPECT_EQ(q.getSize(), 1);
} No newline at end of file

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aqui

src/stack.cpp Outdated
std::cout << temp->data << " ";
temp = temp->next;
}
delete temp;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ojo, hacemos un print, por qué añadis un delete? 👀

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

estoy creando un nodo temporal para poder iterar y hacer temp->data, pero despues de terminar deberia liberar la memoria o no?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ya me di cuenta del error!

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Genera un cambio mimino y comitealo, veamos que hace el test

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Porque me parece que asignas esa dirección de memoria para lectura, entonces el delete no es necesario 🤔
Capaz estoy equivocado

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sisi, estoy creando un puntero pero apunta a direccion de memoria que ya esta creada, con el delete estaria eliminando el ultimo nodo de Stack/Queue. Estaba medio dormido jaja

// Created by nahue on 5/4/2025.
//

#include "../include/dataStructures/stack.hpp"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#include "../include/dataStructures/stack.hpp"
#include "dataStructures/stack.hpp"

src/queue.cpp Outdated
std::cout << temp->data << " ";
temp = temp->next;
}
delete temp;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👀

Correccion en metodos print de Queue y Stack.
@GabrielEValenzuela
Copy link
Owner

@nahuel1114 falla la compilacion 😢

Me ayudo chatgpt por que iba mas alla de mis conocimientos pero habian problemas de linkeo cuando se creaba un Queue con Event y un List con Refugiado. Tambien daba problemas al tratarlos de imprimir por pantalla, ya que la funcion print() de Queue realizaba un cout << temp->data pero al estar apuntando a un Event no sabia como resolverlo.
@nahuel1114
Copy link
Author

nahuel1114 commented Apr 8, 2025 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants