From 312016c1b6ca77d8a52852320a5706852d05bf65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pablo=20Portas=20L=C3=B3pez?= <81629707+TeenBiscuits@users.noreply.github.com> Date: Mon, 6 May 2024 12:03:01 +0200 Subject: [PATCH 1/4] =?UTF-8?q?Implementaci=C3=B3n=20Tema=203=20Lista?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/code/Ejemplos/Tema_3/insertItem.c | 39 ++++++++++++++++++- .../Ejemplos/Tema_3/insertItem_Ordenada.c | 38 +++++++++++++++++- src/Ejemplos/Tema_3/insertItem.c | 39 ++++++++++++++++++- src/Ejemplos/Tema_3/insertItem_Ordenada.c | 38 +++++++++++++++++- 4 files changed, 146 insertions(+), 8 deletions(-) diff --git a/docs/code/Ejemplos/Tema_3/insertItem.c b/docs/code/Ejemplos/Tema_3/insertItem.c index 8aebdb2..d3b1aea 100644 --- a/docs/code/Ejemplos/Tema_3/insertItem.c +++ b/docs/code/Ejemplos/Tema_3/insertItem.c @@ -1,2 +1,37 @@ -// EN CONSTRUCCIÓN -// COLABORA https://github.com/TeenBiscuits/Pro2324 \ No newline at end of file +// SPDX-FileCopyrightText: 2023 Fernando Álvarez +// +// SPDX-License-Identifier: GPL-3.0-only + +bool insertItem(tItemL item, tPosL pos, tList *lista) { + + tPosL posAux; + if (!createNode(&posAux)) { + + return false; + + } else { + + posAux->data = item; + posAux->next = LNULL; //por si acaso + } + if (isEmptyList(*lista)) { + + *lista = posAux; + } else if (pos == LNULL) { + + last(*lista)->next = posAux; + + } else if (pos == *lista) { + + posAux->next = pos; + *lista = posAux; + + } else { + + posAux->next = pos->next; + pos->next = posAux; + posAux->data = pos->data; + pos->data = item; + } + return true; +} \ No newline at end of file diff --git a/docs/code/Ejemplos/Tema_3/insertItem_Ordenada.c b/docs/code/Ejemplos/Tema_3/insertItem_Ordenada.c index 8aebdb2..70c1ca6 100644 --- a/docs/code/Ejemplos/Tema_3/insertItem_Ordenada.c +++ b/docs/code/Ejemplos/Tema_3/insertItem_Ordenada.c @@ -1,2 +1,36 @@ -// EN CONSTRUCCIÓN -// COLABORA https://github.com/TeenBiscuits/Pro2324 \ No newline at end of file +// SPDX-FileCopyrightText: 2023 Fernando Álvarez +// +// SPDX-License-Identifier: GPL-3.0-only + +bool insertItem(tItemL item, tList *lista) { + + tPosL q,p; + if (!createNode(&q)) { + + return false; + + } else { + + q->data = item; + q->next = LNULL; //por si acaso + } + if (isEmptyList(*lista)) { + + *lista = q; + } + else if(item < (*lista)->data){ + + q->next = *lista; + *lista = q; + + } + else{ + + p = findPosition(*lista,item); + q->next = p->next; + p->next = q; + + + } + return true; +} \ No newline at end of file diff --git a/src/Ejemplos/Tema_3/insertItem.c b/src/Ejemplos/Tema_3/insertItem.c index 8aebdb2..d3b1aea 100644 --- a/src/Ejemplos/Tema_3/insertItem.c +++ b/src/Ejemplos/Tema_3/insertItem.c @@ -1,2 +1,37 @@ -// EN CONSTRUCCIÓN -// COLABORA https://github.com/TeenBiscuits/Pro2324 \ No newline at end of file +// SPDX-FileCopyrightText: 2023 Fernando Álvarez +// +// SPDX-License-Identifier: GPL-3.0-only + +bool insertItem(tItemL item, tPosL pos, tList *lista) { + + tPosL posAux; + if (!createNode(&posAux)) { + + return false; + + } else { + + posAux->data = item; + posAux->next = LNULL; //por si acaso + } + if (isEmptyList(*lista)) { + + *lista = posAux; + } else if (pos == LNULL) { + + last(*lista)->next = posAux; + + } else if (pos == *lista) { + + posAux->next = pos; + *lista = posAux; + + } else { + + posAux->next = pos->next; + pos->next = posAux; + posAux->data = pos->data; + pos->data = item; + } + return true; +} \ No newline at end of file diff --git a/src/Ejemplos/Tema_3/insertItem_Ordenada.c b/src/Ejemplos/Tema_3/insertItem_Ordenada.c index 8aebdb2..70c1ca6 100644 --- a/src/Ejemplos/Tema_3/insertItem_Ordenada.c +++ b/src/Ejemplos/Tema_3/insertItem_Ordenada.c @@ -1,2 +1,36 @@ -// EN CONSTRUCCIÓN -// COLABORA https://github.com/TeenBiscuits/Pro2324 \ No newline at end of file +// SPDX-FileCopyrightText: 2023 Fernando Álvarez +// +// SPDX-License-Identifier: GPL-3.0-only + +bool insertItem(tItemL item, tList *lista) { + + tPosL q,p; + if (!createNode(&q)) { + + return false; + + } else { + + q->data = item; + q->next = LNULL; //por si acaso + } + if (isEmptyList(*lista)) { + + *lista = q; + } + else if(item < (*lista)->data){ + + q->next = *lista; + *lista = q; + + } + else{ + + p = findPosition(*lista,item); + q->next = p->next; + p->next = q; + + + } + return true; +} \ No newline at end of file From f5ac0857a38aa2e4c763543d197bedc99f3df441 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pablo=20Portas=20L=C3=B3pez?= <81629707+TeenBiscuits@users.noreply.github.com> Date: Mon, 6 May 2024 12:03:14 +0200 Subject: [PATCH 2/4] Typo CopyList --- docs/code/Ejemplos/Tema_3/copyList.c | 14 +++++++------- src/Ejemplos/Tema_3/copyList.c | 14 +++++++------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/docs/code/Ejemplos/Tema_3/copyList.c b/docs/code/Ejemplos/Tema_3/copyList.c index 5a8bc97..4da64c7 100644 --- a/docs/code/Ejemplos/Tema_3/copyList.c +++ b/docs/code/Ejemplos/Tema_3/copyList.c @@ -2,18 +2,18 @@ // // SPDX-License-Identifier: GPL-3.0-only -bool copyList(tlist L, tList *M) { +bool copyList(tlist listaDest, tList *listaOrig) { tPosl p, q, r; bool ret = true; - createEmptyList(M); - if (!isEmptyList(L)) { - p = L; + createEmptyList(listaOrig); + if (!isEmptyList(listaDest)) { + p = listaDest; while ((p != LNULL) && createNode(&r)) { r->data = p->data; r->next = LNULL; - if (p == L) { - *M = r; + if (p == listaDest) { + *listaOrig = r; q = r; } else { q->next = r; @@ -22,7 +22,7 @@ bool copyList(tlist L, tList *M) { p = p->next; } if (p != LNULL) { - deleteList(M); + deleteList(listaOrig); ret = false; } } diff --git a/src/Ejemplos/Tema_3/copyList.c b/src/Ejemplos/Tema_3/copyList.c index 5a8bc97..4da64c7 100644 --- a/src/Ejemplos/Tema_3/copyList.c +++ b/src/Ejemplos/Tema_3/copyList.c @@ -2,18 +2,18 @@ // // SPDX-License-Identifier: GPL-3.0-only -bool copyList(tlist L, tList *M) { +bool copyList(tlist listaDest, tList *listaOrig) { tPosl p, q, r; bool ret = true; - createEmptyList(M); - if (!isEmptyList(L)) { - p = L; + createEmptyList(listaOrig); + if (!isEmptyList(listaDest)) { + p = listaDest; while ((p != LNULL) && createNode(&r)) { r->data = p->data; r->next = LNULL; - if (p == L) { - *M = r; + if (p == listaDest) { + *listaOrig = r; q = r; } else { q->next = r; @@ -22,7 +22,7 @@ bool copyList(tlist L, tList *M) { p = p->next; } if (p != LNULL) { - deleteList(M); + deleteList(listaOrig); ret = false; } } From 19a8ccf5d383b5fb53ba97584ed00823ea2d1547 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pablo=20Portas=20L=C3=B3pez?= <81629707+TeenBiscuits@users.noreply.github.com> Date: Mon, 6 May 2024 12:07:42 +0200 Subject: [PATCH 3/4] Implementado Tema 4 --- docs/code/Ejemplos/Tema_4/createEmptyQueue.c | 12 ++++++-- docs/code/Ejemplos/Tema_4/dequeue.c | 18 +++++++++-- docs/code/Ejemplos/Tema_4/enqueue.c | 32 ++++++++++++++++++-- docs/code/Ejemplos/Tema_4/front.c | 10 ++++-- docs/code/Ejemplos/Tema_4/isEmptyQueue.c | 11 +++++-- src/Ejemplos/Tema_4/createEmptyQueue.c | 12 ++++++-- src/Ejemplos/Tema_4/dequeue.c | 18 +++++++++-- src/Ejemplos/Tema_4/enqueue.c | 32 ++++++++++++++++++-- src/Ejemplos/Tema_4/front.c | 10 ++++-- src/Ejemplos/Tema_4/isEmptyQueue.c | 11 +++++-- 10 files changed, 146 insertions(+), 20 deletions(-) diff --git a/docs/code/Ejemplos/Tema_4/createEmptyQueue.c b/docs/code/Ejemplos/Tema_4/createEmptyQueue.c index 8aebdb2..4c15d71 100644 --- a/docs/code/Ejemplos/Tema_4/createEmptyQueue.c +++ b/docs/code/Ejemplos/Tema_4/createEmptyQueue.c @@ -1,2 +1,10 @@ -// EN CONSTRUCCIÓN -// COLABORA https://github.com/TeenBiscuits/Pro2324 \ No newline at end of file +// SPDX-FileCopyrightText: 2023 Fernando Álvarez +// +// SPDX-License-Identifier: GPL-3.0-only + +void createEmptyQueue(tQueue *cola){ + + cola->front = QNULL; + cola->rear = QNULL; + +} \ No newline at end of file diff --git a/docs/code/Ejemplos/Tema_4/dequeue.c b/docs/code/Ejemplos/Tema_4/dequeue.c index 8aebdb2..22eb46e 100644 --- a/docs/code/Ejemplos/Tema_4/dequeue.c +++ b/docs/code/Ejemplos/Tema_4/dequeue.c @@ -1,2 +1,16 @@ -// EN CONSTRUCCIÓN -// COLABORA https://github.com/TeenBiscuits/Pro2324 \ No newline at end of file +// SPDX-FileCopyrightText: 2023 Fernando Álvarez +// +// SPDX-License-Identifier: GPL-3.0-only + +void dequeue(tQueue *cola){ + + tPosQ aux; + aux = cola->front; + cola->front = aux->next; + if(cola->front == QNULL){ + + cola->rear = QNULL; + } + free(aux); + +} \ No newline at end of file diff --git a/docs/code/Ejemplos/Tema_4/enqueue.c b/docs/code/Ejemplos/Tema_4/enqueue.c index 8aebdb2..b538be6 100644 --- a/docs/code/Ejemplos/Tema_4/enqueue.c +++ b/docs/code/Ejemplos/Tema_4/enqueue.c @@ -1,2 +1,30 @@ -// EN CONSTRUCCIÓN -// COLABORA https://github.com/TeenBiscuits/Pro2324 \ No newline at end of file +// SPDX-FileCopyrightText: 2023 Fernando Álvarez +// +// SPDX-License-Identifier: GPL-3.0-only + +bool enqueue(tItemQ item,tQueue *cola){ + + tPosQ aux; + + if(!createNode(&aux)){ + + return false; + } + else{ + + aux->data=item; + aux->next=QNULL; + + if(cola->front == QNULL){ + cola->front = aux; + + } + else{ + cola->rear->next = aux; + } + cola->rear = aux; + + return true; + } + +} \ No newline at end of file diff --git a/docs/code/Ejemplos/Tema_4/front.c b/docs/code/Ejemplos/Tema_4/front.c index 8aebdb2..78ad831 100644 --- a/docs/code/Ejemplos/Tema_4/front.c +++ b/docs/code/Ejemplos/Tema_4/front.c @@ -1,2 +1,8 @@ -// EN CONSTRUCCIÓN -// COLABORA https://github.com/TeenBiscuits/Pro2324 \ No newline at end of file +// SPDX-FileCopyrightText: 2023 Fernando Álvarez +// +// SPDX-License-Identifier: GPL-3.0-only + +tItemQ front(tQueue cola){ + + return cola.front->data; +} \ No newline at end of file diff --git a/docs/code/Ejemplos/Tema_4/isEmptyQueue.c b/docs/code/Ejemplos/Tema_4/isEmptyQueue.c index 8aebdb2..390ed3d 100644 --- a/docs/code/Ejemplos/Tema_4/isEmptyQueue.c +++ b/docs/code/Ejemplos/Tema_4/isEmptyQueue.c @@ -1,2 +1,9 @@ -// EN CONSTRUCCIÓN -// COLABORA https://github.com/TeenBiscuits/Pro2324 \ No newline at end of file +// SPDX-FileCopyrightText: 2023 Fernando Álvarez +// +// SPDX-License-Identifier: GPL-3.0-only + +bool isEmptyQueue(tQueue cola){ + + return(cola.front == QNULL); + +} \ No newline at end of file diff --git a/src/Ejemplos/Tema_4/createEmptyQueue.c b/src/Ejemplos/Tema_4/createEmptyQueue.c index 8aebdb2..4c15d71 100644 --- a/src/Ejemplos/Tema_4/createEmptyQueue.c +++ b/src/Ejemplos/Tema_4/createEmptyQueue.c @@ -1,2 +1,10 @@ -// EN CONSTRUCCIÓN -// COLABORA https://github.com/TeenBiscuits/Pro2324 \ No newline at end of file +// SPDX-FileCopyrightText: 2023 Fernando Álvarez +// +// SPDX-License-Identifier: GPL-3.0-only + +void createEmptyQueue(tQueue *cola){ + + cola->front = QNULL; + cola->rear = QNULL; + +} \ No newline at end of file diff --git a/src/Ejemplos/Tema_4/dequeue.c b/src/Ejemplos/Tema_4/dequeue.c index 8aebdb2..22eb46e 100644 --- a/src/Ejemplos/Tema_4/dequeue.c +++ b/src/Ejemplos/Tema_4/dequeue.c @@ -1,2 +1,16 @@ -// EN CONSTRUCCIÓN -// COLABORA https://github.com/TeenBiscuits/Pro2324 \ No newline at end of file +// SPDX-FileCopyrightText: 2023 Fernando Álvarez +// +// SPDX-License-Identifier: GPL-3.0-only + +void dequeue(tQueue *cola){ + + tPosQ aux; + aux = cola->front; + cola->front = aux->next; + if(cola->front == QNULL){ + + cola->rear = QNULL; + } + free(aux); + +} \ No newline at end of file diff --git a/src/Ejemplos/Tema_4/enqueue.c b/src/Ejemplos/Tema_4/enqueue.c index 8aebdb2..b538be6 100644 --- a/src/Ejemplos/Tema_4/enqueue.c +++ b/src/Ejemplos/Tema_4/enqueue.c @@ -1,2 +1,30 @@ -// EN CONSTRUCCIÓN -// COLABORA https://github.com/TeenBiscuits/Pro2324 \ No newline at end of file +// SPDX-FileCopyrightText: 2023 Fernando Álvarez +// +// SPDX-License-Identifier: GPL-3.0-only + +bool enqueue(tItemQ item,tQueue *cola){ + + tPosQ aux; + + if(!createNode(&aux)){ + + return false; + } + else{ + + aux->data=item; + aux->next=QNULL; + + if(cola->front == QNULL){ + cola->front = aux; + + } + else{ + cola->rear->next = aux; + } + cola->rear = aux; + + return true; + } + +} \ No newline at end of file diff --git a/src/Ejemplos/Tema_4/front.c b/src/Ejemplos/Tema_4/front.c index 8aebdb2..78ad831 100644 --- a/src/Ejemplos/Tema_4/front.c +++ b/src/Ejemplos/Tema_4/front.c @@ -1,2 +1,8 @@ -// EN CONSTRUCCIÓN -// COLABORA https://github.com/TeenBiscuits/Pro2324 \ No newline at end of file +// SPDX-FileCopyrightText: 2023 Fernando Álvarez +// +// SPDX-License-Identifier: GPL-3.0-only + +tItemQ front(tQueue cola){ + + return cola.front->data; +} \ No newline at end of file diff --git a/src/Ejemplos/Tema_4/isEmptyQueue.c b/src/Ejemplos/Tema_4/isEmptyQueue.c index 8aebdb2..390ed3d 100644 --- a/src/Ejemplos/Tema_4/isEmptyQueue.c +++ b/src/Ejemplos/Tema_4/isEmptyQueue.c @@ -1,2 +1,9 @@ -// EN CONSTRUCCIÓN -// COLABORA https://github.com/TeenBiscuits/Pro2324 \ No newline at end of file +// SPDX-FileCopyrightText: 2023 Fernando Álvarez +// +// SPDX-License-Identifier: GPL-3.0-only + +bool isEmptyQueue(tQueue cola){ + + return(cola.front == QNULL); + +} \ No newline at end of file From 346ddf6c7f601349f02e4afcf4acd8a6ab29f32e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pablo=20Portas=20L=C3=B3pez?= <81629707+TeenBiscuits@users.noreply.github.com> Date: Mon, 6 May 2024 12:10:11 +0200 Subject: [PATCH 4/4] =?UTF-8?q?A=C3=B1adido=20Colaborador=20Fernando=20?= =?UTF-8?q?=C3=81lvarez?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/cfg/humans.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/cfg/humans.txt b/docs/cfg/humans.txt index 3fc4284..269a087 100644 --- a/docs/cfg/humans.txt +++ b/docs/cfg/humans.txt @@ -10,7 +10,7 @@ Creado gracias a: ¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶ ´¶¶¶¶¶´ - Pablo R. ´´¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶ - Nuria Gómez ´´´´´¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶ - Eliana Reigada -´´´´´´´¶¶¶¶¶¶¶¶¶¶¶¶¶ +´´´´´´´¶¶¶¶¶¶¶¶¶¶¶¶¶ - Fernando Álvarez ´´´´´´´´´¶¶¶¶¶¶¶¶ ´´´´´´´´´´´¶¶¶¶