From 22d76bb673454fba95c8ffd6fd40c1aca805f42f Mon Sep 17 00:00:00 2001 From: Artem Date: Wed, 19 Oct 2022 18:21:07 +0300 Subject: [PATCH 1/2] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8=D0=BB?= =?UTF-8?q?=20=D1=84=D1=83=D0=BD=D0=BA=D1=86=D0=B8=D0=B8=20=D0=BF=D1=80?= =?UTF-8?q?=D0=BE=D0=B2=D0=B5=D1=80=D0=BA=D0=B8=20=D0=BD=D0=B0=20=D0=BF?= =?UTF-8?q?=D1=83=D1=81=D1=82=D0=BE=D1=82=D1=83=20=D0=B8=20=D1=83=D0=B4?= =?UTF-8?q?=D0=B0=D0=BB=D0=B5=D0=BD=D0=B8=D0=B5=20list'=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- list.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/list.c b/list.c index d7db1e8..3ac86b0 100644 --- a/list.c +++ b/list.c @@ -8,4 +8,15 @@ typedef struct Node { struct List { Node *head; -}; \ No newline at end of file +}; + +bool isEmpty(List* list) { + return list->head == NULL; +} + +int clear(List* list) { + while (!isEmpty(list)) { + int errorCode = 0; + delete(list, &errorCode); + } +} \ No newline at end of file From 4e598300c19b3a9e6b8bd0af6fea84391ef744b5 Mon Sep 17 00:00:00 2001 From: Artem Date: Wed, 19 Oct 2022 18:37:24 +0300 Subject: [PATCH 2/2] =?UTF-8?q?=D0=A1=D0=B4=D0=B5=D0=BB=D0=B0=D0=BB=20?= =?UTF-8?q?=D1=84=D1=83=D0=BD=D0=BA=D1=86=D0=B8=D1=8E=20changeNode?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- list.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/list.c b/list.c index 3ac86b0..42f2c3e 100644 --- a/list.c +++ b/list.c @@ -19,4 +19,21 @@ int clear(List* list) { int errorCode = 0; delete(list, &errorCode); } +} + +int changeNode(List* list, int position, int value) { + if (isEmpty(list)) { + return -1; + } + + Node* walker = list->head; + while (walker->position != position) { + if (walker->next == NULL) { + return -1; + } + walker = walker->next; + } + + walker->value = value; + return 0; } \ No newline at end of file