This repository has been archived by the owner on Dec 31, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #133 from TeenBiscuits/implementacion
Implementaciones Tema 3 y 4
- Loading branch information
Showing
17 changed files
with
307 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
|
||
} |
Oops, something went wrong.