Skip to content
This repository has been archived by the owner on Dec 12, 2024. It is now read-only.

Implementaciones Tema 3 y 4 #133

Merged
merged 4 commits into from
May 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/cfg/humans.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Creado gracias a:
¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶ ´¶¶¶¶¶´ - Pablo R.
´´¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶ - Nuria Gómez
´´´´´¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶¶ - Eliana Reigada
´´´´´´´¶¶¶¶¶¶¶¶¶¶¶¶¶
´´´´´´´¶¶¶¶¶¶¶¶¶¶¶¶¶ - Fernando Álvarez
´´´´´´´´´¶¶¶¶¶¶¶¶
´´´´´´´´´´´¶¶¶¶

Expand Down
14 changes: 7 additions & 7 deletions docs/code/Ejemplos/Tema_3/copyList.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -22,7 +22,7 @@ bool copyList(tlist L, tList *M) {
p = p->next;
}
if (p != LNULL) {
deleteList(M);
deleteList(listaOrig);
ret = false;
}
}
Expand Down
39 changes: 37 additions & 2 deletions docs/code/Ejemplos/Tema_3/insertItem.c
Original file line number Diff line number Diff line change
@@ -1,2 +1,37 @@
// EN CONSTRUCCIÓN
// COLABORA https://github.com/TeenBiscuits/Pro2324
// 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;
}
38 changes: 36 additions & 2 deletions docs/code/Ejemplos/Tema_3/insertItem_Ordenada.c
Original file line number Diff line number Diff line change
@@ -1,2 +1,36 @@
// EN CONSTRUCCIÓN
// COLABORA https://github.com/TeenBiscuits/Pro2324
// 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;
}
12 changes: 10 additions & 2 deletions docs/code/Ejemplos/Tema_4/createEmptyQueue.c
Original file line number Diff line number Diff line change
@@ -1,2 +1,10 @@
// EN CONSTRUCCIÓN
// COLABORA https://github.com/TeenBiscuits/Pro2324
// SPDX-FileCopyrightText: 2023 Fernando Álvarez
//
// SPDX-License-Identifier: GPL-3.0-only

void createEmptyQueue(tQueue *cola){

cola->front = QNULL;
cola->rear = QNULL;

}
18 changes: 16 additions & 2 deletions docs/code/Ejemplos/Tema_4/dequeue.c
Original file line number Diff line number Diff line change
@@ -1,2 +1,16 @@
// EN CONSTRUCCIÓN
// COLABORA https://github.com/TeenBiscuits/Pro2324
// 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);

}
32 changes: 30 additions & 2 deletions docs/code/Ejemplos/Tema_4/enqueue.c
Original file line number Diff line number Diff line change
@@ -1,2 +1,30 @@
// EN CONSTRUCCIÓN
// COLABORA https://github.com/TeenBiscuits/Pro2324
// 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;
}

}
10 changes: 8 additions & 2 deletions docs/code/Ejemplos/Tema_4/front.c
Original file line number Diff line number Diff line change
@@ -1,2 +1,8 @@
// EN CONSTRUCCIÓN
// COLABORA https://github.com/TeenBiscuits/Pro2324
// SPDX-FileCopyrightText: 2023 Fernando Álvarez
//
// SPDX-License-Identifier: GPL-3.0-only

tItemQ front(tQueue cola){

return cola.front->data;
}
11 changes: 9 additions & 2 deletions docs/code/Ejemplos/Tema_4/isEmptyQueue.c
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
// EN CONSTRUCCIÓN
// COLABORA https://github.com/TeenBiscuits/Pro2324
// SPDX-FileCopyrightText: 2023 Fernando Álvarez
//
// SPDX-License-Identifier: GPL-3.0-only

bool isEmptyQueue(tQueue cola){

return(cola.front == QNULL);

}
14 changes: 7 additions & 7 deletions src/Ejemplos/Tema_3/copyList.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -22,7 +22,7 @@ bool copyList(tlist L, tList *M) {
p = p->next;
}
if (p != LNULL) {
deleteList(M);
deleteList(listaOrig);
ret = false;
}
}
Expand Down
39 changes: 37 additions & 2 deletions src/Ejemplos/Tema_3/insertItem.c
Original file line number Diff line number Diff line change
@@ -1,2 +1,37 @@
// EN CONSTRUCCIÓN
// COLABORA https://github.com/TeenBiscuits/Pro2324
// 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;
}
38 changes: 36 additions & 2 deletions src/Ejemplos/Tema_3/insertItem_Ordenada.c
Original file line number Diff line number Diff line change
@@ -1,2 +1,36 @@
// EN CONSTRUCCIÓN
// COLABORA https://github.com/TeenBiscuits/Pro2324
// 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;
}
12 changes: 10 additions & 2 deletions src/Ejemplos/Tema_4/createEmptyQueue.c
Original file line number Diff line number Diff line change
@@ -1,2 +1,10 @@
// EN CONSTRUCCIÓN
// COLABORA https://github.com/TeenBiscuits/Pro2324
// SPDX-FileCopyrightText: 2023 Fernando Álvarez
//
// SPDX-License-Identifier: GPL-3.0-only

void createEmptyQueue(tQueue *cola){

cola->front = QNULL;
cola->rear = QNULL;

}
18 changes: 16 additions & 2 deletions src/Ejemplos/Tema_4/dequeue.c
Original file line number Diff line number Diff line change
@@ -1,2 +1,16 @@
// EN CONSTRUCCIÓN
// COLABORA https://github.com/TeenBiscuits/Pro2324
// 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);

}
Loading