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

Añadidas Implementaciones Tema 3 #131

Merged
merged 1 commit into from
May 3, 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
32 changes: 30 additions & 2 deletions docs/code/Ejemplos/Tema_3/copyList.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: 2024 Eliana Reigada
//
// SPDX-License-Identifier: GPL-3.0-only

bool copyList(tlist L, tList *M) {
tPosl p, q, r;
bool ret = true;

createEmptyList(M);
if (!isEmptyList(L)) {
p = L;
while ((p != LNULL) && createNode(&r)) {
r->data = p->data;
r->next = LNULL;
if (p == L) {
*M = r;
q = r;
} else {
q->next = r;
q = r;
}
p = p->next;
}
if (p != LNULL) {
deleteList(M);
ret = false;
}
}
return ret;
}
9 changes: 7 additions & 2 deletions docs/code/Ejemplos/Tema_3/createEmptyList.c
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
// EN CONSTRUCCIÓN
// COLABORA https://github.com/TeenBiscuits/Pro2324
// SPDX-FileCopyrightText: 2024 Eliana Reigada
//
// SPDX-License-Identifier: GPL-3.0-only

void createEmptyList(tList *lista) {
lista->indice = LNULL;
}
18 changes: 16 additions & 2 deletions docs/code/Ejemplos/Tema_3/deleteAtPosition.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: 2024 Eliana Reigada
//
// SPDX-License-Identifier: GPL-3.0-only

void deleteAtPosition(tPosL pos, tList *lista) {
tPosl posAux;

if (pos == *lista)
*lista = (*lista)->next;
else {
for (posAux = *lista; posAux->next != pos; posAux = posAux->next);
posAux->next = pos->next;
}

free(pos);
}
14 changes: 12 additions & 2 deletions docs/code/Ejemplos/Tema_3/deleteList.c
Original file line number Diff line number Diff line change
@@ -1,2 +1,12 @@
// EN CONSTRUCCIÓN
// COLABORA https://github.com/TeenBiscuits/Pro2324
// SPDX-FileCopyrightText: 2024 Eliana Reigada
//
// SPDX-License-Identifier: GPL-3.0-only

void deleteList(tList *lista) {
tPosL posAux;
while (*lista != LNULL) {
posAux = *lista;
*lista = (*lista)->next;
free(posAux);
}
}
11 changes: 9 additions & 2 deletions docs/code/Ejemplos/Tema_3/findItem.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: 2024 Eliana Reigada
//
// SPDX-License-Identifier: GPL-3.0-only

tPosL findItem(tItem item, tList lista) {
tPosL posAux;
for (posAux = lista; (posAux != LNULL) && (posAux->data != item); posAux = posAux->next);
return posAux;
}
9 changes: 7 additions & 2 deletions docs/code/Ejemplos/Tema_3/first.c
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
// EN CONSTRUCCIÓN
// COLABORA https://github.com/TeenBiscuits/Pro2324
// SPDX-FileCopyrightText: 2024 Eliana Reigada
//
// SPDX-License-Identifier: GPL-3.0-only

tPosL first(tList lista) {
return lista;
}
9 changes: 7 additions & 2 deletions docs/code/Ejemplos/Tema_3/getItem.c
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
// EN CONSTRUCCIÓN
// COLABORA https://github.com/TeenBiscuits/Pro2324
// SPDX-FileCopyrightText: 2024 Eliana Reigada
//
// SPDX-License-Identifier: GPL-3.0-only

tItem getItem(tPosL pos, tList lista) {
return pos->data;
}
9 changes: 7 additions & 2 deletions docs/code/Ejemplos/Tema_3/isEmptyList.c
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
// EN CONSTRUCCIÓN
// COLABORA https://github.com/TeenBiscuits/Pro2324
// SPDX-FileCopyrightText: 2024 Eliana Reigada
//
// SPDX-License-Identifier: GPL-3.0-only

bool isEmptyList(tLIst lista) {
return lista == LNULL;
}
11 changes: 9 additions & 2 deletions docs/code/Ejemplos/Tema_3/last.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: 2024 Eliana Reigada
//
// SPDX-License-Identifier: GPL-3.0-only

tPosL last(tList lista) {
tPosL posAux;
for (posAux = lista; posAux->next != LNULL; posAux->next);
return posAux;
}
9 changes: 7 additions & 2 deletions docs/code/Ejemplos/Tema_3/next.c
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
// EN CONSTRUCCIÓN
// COLABORA https://github.com/TeenBiscuits/Pro2324
// SPDX-FileCopyrightText: 2024 Eliana Reigada
//
// SPDX-License-Identifier: GPL-3.0-only

tPosL next(tPosL pos, tList lista) {
return pos->next;
}
11 changes: 9 additions & 2 deletions docs/code/Ejemplos/Tema_3/previous.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: 2024 Eliana Reigada
//
// SPDX-License-Identifier: GPL-3.0-only

tPosL previous(tPosL pos, tList L) {
tPosL posAux;
for (posAux = L; posAux->next != pos; posAux = posAux->next);
return posAux;
}
9 changes: 7 additions & 2 deletions docs/code/Ejemplos/Tema_3/updateItem.c
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
// EN CONSTRUCCIÓN
// COLABORA https://github.com/TeenBiscuits/Pro2324
// SPDX-FileCopyrightText: 2024 Eliana Reigada
//
// SPDX-License-Identifier: GPL-3.0-only

void updateItem(tItem item, tPosL pos, tList *lista) {
pos->data = item;
}
32 changes: 30 additions & 2 deletions src/Ejemplos/Tema_3/copyList.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: 2024 Eliana Reigada
//
// SPDX-License-Identifier: GPL-3.0-only

bool copyList(tlist L, tList *M) {
tPosl p, q, r;
bool ret = true;

createEmptyList(M);
if (!isEmptyList(L)) {
p = L;
while ((p != LNULL) && createNode(&r)) {
r->data = p->data;
r->next = LNULL;
if (p == L) {
*M = r;
q = r;
} else {
q->next = r;
q = r;
}
p = p->next;
}
if (p != LNULL) {
deleteList(M);
ret = false;
}
}
return ret;
}
9 changes: 7 additions & 2 deletions src/Ejemplos/Tema_3/createEmptyList.c
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
// EN CONSTRUCCIÓN
// COLABORA https://github.com/TeenBiscuits/Pro2324
// SPDX-FileCopyrightText: 2024 Eliana Reigada
//
// SPDX-License-Identifier: GPL-3.0-only

void createEmptyList(tList *lista) {
lista->indice = LNULL;
}
18 changes: 16 additions & 2 deletions src/Ejemplos/Tema_3/deleteAtPosition.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: 2024 Eliana Reigada
//
// SPDX-License-Identifier: GPL-3.0-only

void deleteAtPosition(tPosL pos, tList *lista) {
tPosl posAux;

if (pos == *lista)
*lista = (*lista)->next;
else {
for (posAux = *lista; posAux->next != pos; posAux = posAux->next);
posAux->next = pos->next;
}

free(pos);
}
14 changes: 12 additions & 2 deletions src/Ejemplos/Tema_3/deleteList.c
Original file line number Diff line number Diff line change
@@ -1,2 +1,12 @@
// EN CONSTRUCCIÓN
// COLABORA https://github.com/TeenBiscuits/Pro2324
// SPDX-FileCopyrightText: 2024 Eliana Reigada
//
// SPDX-License-Identifier: GPL-3.0-only

void deleteList(tList *lista) {
tPosL posAux;
while (*lista != LNULL) {
posAux = *lista;
*lista = (*lista)->next;
free(posAux);
}
}
11 changes: 9 additions & 2 deletions src/Ejemplos/Tema_3/findItem.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: 2024 Eliana Reigada
//
// SPDX-License-Identifier: GPL-3.0-only

tPosL findItem(tItem item, tList lista) {
tPosL posAux;
for (posAux = lista; (posAux != LNULL) && (posAux->data != item); posAux = posAux->next);
return posAux;
}
9 changes: 7 additions & 2 deletions src/Ejemplos/Tema_3/first.c
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
// EN CONSTRUCCIÓN
// COLABORA https://github.com/TeenBiscuits/Pro2324
// SPDX-FileCopyrightText: 2024 Eliana Reigada
//
// SPDX-License-Identifier: GPL-3.0-only

tPosL first(tList lista) {
return lista;
}
9 changes: 7 additions & 2 deletions src/Ejemplos/Tema_3/getItem.c
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
// EN CONSTRUCCIÓN
// COLABORA https://github.com/TeenBiscuits/Pro2324
// SPDX-FileCopyrightText: 2024 Eliana Reigada
//
// SPDX-License-Identifier: GPL-3.0-only

tItem getItem(tPosL pos, tList lista) {
return pos->data;
}
9 changes: 7 additions & 2 deletions src/Ejemplos/Tema_3/isEmptyList.c
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
// EN CONSTRUCCIÓN
// COLABORA https://github.com/TeenBiscuits/Pro2324
// SPDX-FileCopyrightText: 2024 Eliana Reigada
//
// SPDX-License-Identifier: GPL-3.0-only

bool isEmptyList(tLIst lista) {
return lista == LNULL;
}
11 changes: 9 additions & 2 deletions src/Ejemplos/Tema_3/last.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: 2024 Eliana Reigada
//
// SPDX-License-Identifier: GPL-3.0-only

tPosL last(tList lista) {
tPosL posAux;
for (posAux = lista; posAux->next != LNULL; posAux->next);
return posAux;
}
9 changes: 7 additions & 2 deletions src/Ejemplos/Tema_3/next.c
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
// EN CONSTRUCCIÓN
// COLABORA https://github.com/TeenBiscuits/Pro2324
// SPDX-FileCopyrightText: 2024 Eliana Reigada
//
// SPDX-License-Identifier: GPL-3.0-only

tPosL next(tPosL pos, tList lista) {
return pos->next;
}
11 changes: 9 additions & 2 deletions src/Ejemplos/Tema_3/previous.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: 2024 Eliana Reigada
//
// SPDX-License-Identifier: GPL-3.0-only

tPosL previous(tPosL pos, tList L) {
tPosL posAux;
for (posAux = L; posAux->next != pos; posAux = posAux->next);
return posAux;
}
9 changes: 7 additions & 2 deletions src/Ejemplos/Tema_3/updateItem.c
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
// EN CONSTRUCCIÓN
// COLABORA https://github.com/TeenBiscuits/Pro2324
// SPDX-FileCopyrightText: 2024 Eliana Reigada
//
// SPDX-License-Identifier: GPL-3.0-only

void updateItem(tItem item, tPosL pos, tList *lista) {
pos->data = item;
}
Loading